I would like to make a div that covers the entire page. I put a css style with height:100% but this covers only the viewable area. I want it to also cover the area when I scroll down.
A:
I'm not sure what you're doing with this div, but you can style the element as well.
coding_hero
2010-07-14 21:51:35
+1
A:
Use position:fixed
this way your div will remain over the whole viewable area continuously ..
give your div a class overlay
and create the following rule in your CSS
.overlay{
opacity:0.8;
background-color:#ccc;
position:fixed;
width:100%;
height:100%;
top:0px;
left:0px;
z-index:1000;
}
Gaby
2010-07-14 21:53:49
+2
A:
<style type="text/css">
html, body {
margin:0;
padding:0;
height:100%;
}
#test {
position:absolute;
display:block;
background:#ccc;
height:100%;
width:100%;
}
</style>
Vasil Dakov
2010-07-14 21:56:39
+1 for zeroing the body.
banzaimonkey
2010-07-14 21:58:13
this will not work .. `position:absolute` with 100% width and height will still only fit the viewport. if you scroll, it will scroll up and the rest of the page will be without the overlay ..
Gaby
2010-07-14 23:06:19
A:
Here is a great article on how to do just that...
http://james.padolsey.com/javascript/get-document-height-cross-browser/
exoboy
2010-07-15 03:11:40