Im trying to set the background color of a div tag that resides in a body tag to the entire screen but I have not found a satisfactory solution to this problem:
...
<body>
<div>
</div>
</body>
...
How can I set the background color of the whole page from the div tag that resides in body?
doing
div {
background-color: green;
}
doesn't turn the background green.
Why can't you just set the body's background color?
Either way you'll have to do something like this:
CSS:
html, body { padding: 0; margin: 0; height: 100%; }
#fake_body { width: 100%; height: 100%; background: #000; }
HTML:
<html>
<body>
<div id="fake_body"></div>
</body>
</html>
Unless I'm missing something, that should work. jsFiddle
Just make sure the div covers the entire page I suppose.
#divID {
background-color: #fff;
top: 0;bottom: 0;right: 0;left: 0;
position: absolute;
}
Note:
Woah, 2011.. I guess I am late to the party.. by far. Anyways, for the sake of google.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.