views:

836

answers:

9

I have been working on this for the past couple of hours, and searching the web and stackoverflow hasn't been much support. How do I make #gradient and #holes fill the entire page?

I have used the Inspect Element feature in Safari, and when I highlight the body element it does not fill the entire window.alt text

HTML:

<body>

    <div id="gradient"></div>
    <div id="holes"></div>

    <div id="header">Header Text</div>
</body>

CSS:

    html, body {
    height:100%;

    margin:0;
    padding:0;
}

body {
    background-image:url(../Images/Tile.png);
    background-color:#7D7D7D;
    background-repeat:repeat;
}

#gradient {
    background-image:url(../Images/Background.png);
    background-repeat:repeat-x;

    position:absolute;
    top:0px;
    left:0px;
    height:100%;
    right:0px;
}

#holes {
    background-image:url(../Images/Holes.png);
    background-repeat:repeat;

    position:absolute;
    top:2px;
    left:2px;
    height:100%;
    right:0px;
}

#header {
    background-image:url(../Images/Header.png);
    background-repeat:repeat-x;

    position:absolute;
    top:0px;
    left:0px;
    width:100%;

    padding-top:24px;
    height:49px; /* 73 - padding */

    color:rgb(113, 120, 128);
    font-family:Helvetica, Arial;
    font-weight:bold;
    font-size:24px;
    text-align:center;
    text-shadow:#FFF 0px 1px 0px;
}
A: 

If I remember correctly, in order be able to specify positions of a container's (A) child containers (B1, B2, ...), it's position should be absolute. Your body container's position isn't.

I guess you should add the position:absolute; property to the html,body selector.

xtofl
Tried, still no success
woody993
A: 

Look into min-height

ghoppe
For which element/selector?
woody993
For your #gradient and #holes, set min-height: 100%
ghoppe
No luck there with min-height
woody993
Why have you set both left: and right: properties to contradictory values?
ghoppe
try using a #wrapper div to contain #gradient #holes #header and set #wrapper {min-height: 100%}
ghoppe
How contradictory, it tapes the left margin to 0px and right margin to the 0px, equal to 100% width
woody993
No change with #wrapper
woody993
Any reason why you don't want to add the background-image:url(../Images/Tile.png); to the html element instead of the body element?
ghoppe
A: 

The best way is to use javascript. min-height is not supported by every browser.

Javascript using prototype:

<script type="text/javascript">
var height = $(document.body).getHeight();
document.write('<div id="yourdiv" style="height:'+height+'px;width:100%;"></div>');
</script>
I'm not sure writing the div into the page directly is the best idea: why not use $('#divName).css('height', height) instead [or the prototype equivalent]?
Ed Woodcock
No need to use javascript. If you must have compatibility with IE6 (blech!) since IE < 6 treats height incorrectly as min-height, it's better to use the star html hack:* html #gradient {height:100%;}
ghoppe
Least amount of visitors will be using windows, if any.
woody993
A: 
Gaby
I have now, still nothing
woody993
yes .. i posted without checking .. it will only work for the overflowing element .. (the one whose content will go beyond the bottom of the viewport..)
Gaby
posted a different approach .. have a look..
Gaby
A: 

I think you did it right. This is working in Chrome (WebKit too!) and in IE7/8/Quirks whenever you put width: 100% on #gradient and #holes, can't test safari on Mac right now (only have it at home) but in theory you should be seeing it properly.

That said, maybe this is a doctype thing, try different ones?

F.Aquino
Tried XHTML 1.1, 1.0 Transitional, 4.01 Transitional
woody993
A: 

To be honest, I think I'm just going to overflow:auto on my content so that the entire page does not need to be scrolled

woody993
A: 

Well it looks to me that your element with all the content is floated. If it is then its not going to expand the body unless it is cleared.

prodigitalson
I think he might have it, totally missed that as the css for the content box wasn't posted!
ghoppe
A: 

Have you tried setting up like this?

#holes {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

Will stretch the element to fill the whole page area

Pete B