I've been trying all methods to stretch the background color to fill 100% of the page but it doesn't work in Firefox 3. It just stretches to where the content is. It seems to work fine in IE 7, but there is some space to scroll up and down.

Here's my CSS:

body {
	height: 100%;
	background-color: #666;
	margin: 0px;
	margin-top: -1px;
	background-image: url(Background.jpg);

.container {
	height: 100% !important;
	min-height: 100%;
	background-color: #252525;
	width: 80%;
	min-width: 1000px;
	max-width: 1400px;
	border: #444 1px solid;
	margin: 0px;

And this is my HTML:


<div class="container"> <!-- Open -->
<div class="header"></div> <!-- Header -->

<!--       Content      -->
<div class="page">
<div class="content">Content</div><div class="sidebar"> Sidebar </div>

<!--    Footer     -->
<div class="footer">
<br /><br /><br /><br /><br /><p><span class="footercont">

<div class="fill"></div> <!-- Fill -->

</div> <!-- Close -->


Many thanks to those who help me.

Recommended Answers

All 7 Replies

yea never gotten 100% height working in all browsers w/o js. change your .container to #container

function divSize() {
	winH = document.body.offsetHeight;
	totalHeight = document.getElementById('container').offsetHeight;
if(winH > totalHeight) {
 document.getElementById('container').style.height=winH + "px";

window.onresize = function() {

If the div is less than the window height it changes the div height to match the window, if its greater then the 100% will work fine. Also when the window is resized it changes the height to make sure its up to date.

add this to the head of the pages

window.onload = function() {

or <body onload="divSize();">

Do I need to do anything to the html, cause it ain't working.

It can't be done.

The web is NOT designed to fill a screen. You provide content, and it expands downward to fill whatever area is needed, running off the screen downward if necessary.

Remember that different computers have different resolutions. Combine that with different browsers, and it is quite impossible to make a web page that fits into a screen.

IE has nonstandard extensions to do this, but nobody else implements them.

have you tried: html

                          background-color: .............

Yes I did.

Member Avatar for Rhyan

You may want to check this blog posting.

I think you can modify it in order to achieve your goals. Hope it solves your issue.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.