Forum Moderators: not2easy

Message Too Old, No Replies

Netscape container div background issue

Netscape doesn't render background colors/graphics specified for container

         

saratech

9:46 pm on May 9, 2007 (gmt 0)

10+ Year Member



I've replaced my background image for the container in this to red for display purposes. In all browsers except Netscape (not just 4.x, but all versions), this displays the body background color and then fills the container with my image (in this case, the color red).

All versions of Netscape do not show the red, they remain transparent. I have no idea why this is or how to fix it. Does anyone have any idea? (as an aside, this is my first post here, so let me know if I need to provide more info.)

Below is the relevant code:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<head>
<style>
body {
background-image: none;
margin: 0px;
background-color: #8b726f;
width:760px;
}
#container {
background-color:red;
width: 760px;
margin: 0 auto;
padding-top: 0px;
position:relative;
}
div#leftnav {
width: 160px;
height: 100%;
margin: 0;
padding: 0;
float:left;
}
div#bodyContainer {
float: left;
width: 600px;
height: 100%;
}
div.column1 {
float: left;
width: 368px;
padding: 0 10px 10px 10px;
}
div.column2 {
height: 100%;
float: right;
width: 180px;
padding: 0 10px 10px 10px;
}
</style>
</head>
<body>
<div id="container">
<div id="leftnav">
<h2>Left navigation </h2>
</div>
<div id="bodyContainer">
<div class="column1">
<h2>Center column </h2>
</div>
<div class="column2">
<h2>Right Column </h2>
</div>
</div>
</div>
</body>
</html>

Xapti

5:20 am on May 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well it's probably acting in quirks mode right now, that's my guess. Include the DTD link in your doctype.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

Other than that, I can't say much except this: Netscape is now a pretty lousy browser, and hardly anyone uses it. I wouldn't really worry about it if I were you, it's like catering to Win3.1 users. (granted, I know there's some very new versions of Netscape around)

[edited by: Xapti at 5:20 am (utc) on May 10, 2007]

SuzyUK

7:51 am on May 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi saratech and Welcome to WebmasterWorld!

Xapti is right about the Doctype, which may go on to cause other problems with floated layouts for you, so perhaps you might like to read up on them:

for this problem I though I think you may just need to contain your floats. Floated elements are well, floating ;) not really there, and their container div no longer knows they exist, so it doesn't know to stretch to clear them, which is possibly why your background is 'missing'

IE as you will read is likely doing it because of it's quirks ;) there are ways to clear floats properly, either by floating the container itself, or you can add something like

<br style="clear: both;">
to the HTML just before the closing container div tag. or you can set
overflow: auto;
onto the container CSS itself.

Clearing elements used to be used abundantly because support for the overflow method was/is not quite complete, and if you really are using Netscape 6/7, I think that is one of the browsers that does not support overflow. You may also want to take a look for the "easyclearing" method on P.I.E. - I still have that method in place in some s/sheets because of Netscape. Between using it and overflow I find you can clear the floats without clearing divs (extra HTML) usually.

Suzy