Forum Moderators: not2easy
I have a page that uses a DIV entitled "container" with this CSS:
#container {
width: 700px;
border-left: 1px solid #000;
border-right: 1px solid #000;
background-color: #CCCCFF;
position: relative;
margin-top: 80px;
margin-left: auto;
margin-right: auto;
display: block;
}
On Opera and IE, the DIV displays as would be expected. However, Netscape recognizes the DIV for positioning--expanding it to 800px, for example, expands everything within as predicted--but neither the borders nor the background-color display. I've tried fiddling with z-index values to no effect, and only added "display: block" in an attempt to fix this. Any help anyone has to offer would be highly appreciated.
[edited by: nate451 at 1:10 am (utc) on Mar. 26, 2004]
The HTML is quite straight-forward, as you can imagine. Is anyone acquainted with any problem that might theoretically reveal itself this way? I'm not even sure where to look. I've searched for conflicting ids, unclosed tags, and I can't find anything.
I have:
html, body {
border: 0px;
margin: 0px;
padding: 0px;
height: 100%;
background-color: #333333;
font-family: trebuchet ms, garamond;
}
#container {
width: 700px;
border: solid red 2px;
background-color: #CCC;
position: relative;
margin-top: 80px;
margin-left: auto;
margin-right: auto;
}
#text {
padding-top: 35px;
padding-left: 20px;
padding-bottom: 20px;
width: 460px;
position: relative;
float: left;
}
#side {
position: relative;
width: 200px;
padding-top: 120px;
float: right;
}
These should be the relevant DIVs. Anyone know what is making Netscape not recognize these as filling the container DIV?
[edited by: nate451 at 1:40 am (utc) on Mar. 26, 2004]
Workarounds? Explicitly specify a height, or ensure that at least one child element is a non-floating, non-positioned element.
For some technical reading on the subject:
[w3.org...]
[w3.org...]
another one would be to float the container - 100% width
Floated parents will expand to contained their floated children.
This gives a small problem with centering but that it easily overcome by moving your 700px width and margin: 0 auto; to the body element instead.
Note: this only works in IE with strict doctype.
body {width: 700px; margin: 0 auto;}
#container {
float: left;
width: 100%;
border: solid red 2px;
background-color: #CCC;
position: relative;
margin-top: 80px;
}
Suzy