Elements in fixed position stay in place, even when a document is scrolled and are positioned relative to the browser's viewport.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en'>
<head>
<title>Fixed Positioning</title>
<style type='text/css'>
body {
background: lightyellow url('http://java2s.com/style/logo.png') fixed;
}
div#fixed-top {
position: absolute;
top: expression(eval(documentElement.scrollTop) + 5);
}
div#fixed-bottom {
position: absolute;
bottom: auto;
top: expression(
(documentElement.scrollTop + documentElement.clientHeight - this.clientHeight) - 7
);
}
</style>
</head>
<body>
<div id='fixed-top'>
</div>
<div id='fixed-bottom'>
</div>
</p>
</body>
</html>
Related examples in the same category