07 June 2007

CSS Tip #1

If you have a div that needs to go the height of the entire page the way a body tag can. For instance, if you wanted one background image for the body tag and another for a div tag, like having multiple borders. I ran into this issue when setting:


#bg2
{
height:100%;
width:700px;
margin-left: auto;
margin-right: auto;
}


the height gets ignored on most browsers, make sure to include:

html, body
{
height:100%;
}

body
{
width:800px;
margin-left: auto;
margin-right: auto;
}


so if you have html head../head body div id="bg2" .../div /body /html

Labels: , , ,