When I scroll down my div background-color still does not update, it's 100% height to the bottom of the page. See my screenshot here:
See the following code on my JSFiddle example:
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
body {
width: 100%; height: 100%; margin: 0 auto;
background: orange; color: #000000;
font-family: "Century Gothic", "Apple Gothic", Verdana, sans-serif;
}
#container {
width: 800px; height: 100%;
position: absolute; left: 0; right: 0; margin-left: auto; margin-right: auto;
}
#page {
background: #FFFFFF;
padding: 1.1em;
position: absolute; top: 0; bottom: 0; left: 3px; right: 3px
}
</style>
</head>
<body>
<div id="container">
<div id="page">
<u>Page Title</u>
<br /><br /><br /><br />
<b>Content</b><br /><br /><br /><br />
Lorem Ipsum<br /><br />Lorem Ipsum<br /><br />
Lorem Ipsum<br /><br />Lorem Ipsum<br /><br />
Lorem Ipsum<br /><br />Lorem Ipsum<br /><br />
Lorem Ipsum<br /><br />Lorem Ipsum<br /><br />
Lorem Ipsum<br /><br />Lorem Ipsum<br /><br />
Lorem Ipsum<br /><br />Lorem Ipsum<br /><br />
Lorem Ipsum<br /><br />Lorem Ipsum<br /><br />
Lorem Ipsum<br /><br />Lorem Ipsum<br /><br />
Lorem Ipsum<br /><br />Lorem Ipsum<br /><br />
Lorem Ipsum<br /><br />Lorem Ipsum<br /><br />
Lorem Ipsum<br /><br />Lorem Ipsum<br /><br />
Lorem Ipsum<br /><br />Lorem Ipsum<br /><br />
</div>
</div>
</body>
</html>
How do I tell the div #page
to stretch its white background-color
further on to the bottom of the page when I scroll down?
If I use min-height: 100%;
and position: relative;
in #page
it
produces the scrollbar on the right:
Change position: absolute
to position: relative
Add this
#page {
position: relative;
}
Fiddle
You can add min-height:100%
Updated Fiddle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With