Forum Moderators: not2easy

Message Too Old, No Replies

Disappearing background in main container consist of float elements

IE Bug in Float (Background Disappear)

         

vanjustin

9:44 am on Sep 7, 2007 (gmt 0)

10+ Year Member



Hi everybody i have a problem in IE im a new coder in css.Display is ok in Firefox!
I have a div contentwrapper which composed of floating elements inside this div. Contentwrapper has a background image which disappear in IE
------------------------------------------------------
This is the stylesheet
#contentwrapper{
background: url(img/insidepage/bg_content.jpg) top repeat-y; height:auto;
}

#sidenav {
margin-top:10px;
margin-left:10px;
float:left;
width:180px;
padding:10px;
text-align:center;
border-right:#59574a dashed 1px;}
#sidenav ul { margin-top:10px;}
#sidenav ul li {
margin-bottom:10px;}
#sidenav a:hover{text-decoration:underline;}

#content {
float:left;
width:500px;
margin-top:15px;
line-height:15px;
margin-left:20px;}
#content a, #content p {
font-family:Tahoma,Arial, Helvetica, sans-serif;
font-size:11px;
color:#000;
text-decoration:none;
line-height:15px;}
#content a {
color:#000066;
text-decoration:none;}
#content a:hover,#content a:focus{
text-decoration:underline;}

-------------------------------------------
XHTML

<div id="contentwrapper">
<div id="sidenav">
<!-- SOME CODE HERE -->
</div>
<div id="content">
<!-- SOME CODE HERE -->
</div>

<br class="clearfloat" />
</div>
------------------------------------------------
Does anybody brilliant minds could help me to fix this problem. Thanks ahead .....

Marshall

10:14 am on Sep 7, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi vanjustin, welcome to WebmasterWorld.

Try removing the height:auto from the background.

Marshall

vanjustin

11:07 am on Sep 7, 2007 (gmt 0)

10+ Year Member



Hi marshall tnx for the welcome message but unfortunately your solution is not working. Here's Doctype I've been using <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Im trying to test in in IE 7.0 but the container contentwrapper didn't expand height as the inside div expand its height. Maybe that is the specifically the problem but it is ok in FIREFOX. Do you have any idea on what's going on with IE or tricks to the problem. thnx for your replies

Marshall

11:38 am on Sep 7, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I am assuming that <br class="clearfloat" /> means clear: both. If not, change to <br style="clear:both;" />. You are correct that you need something there to force the container down, unless you specify the containers's height in px or em's. Another option in place of the <br> is
<div style="height:1px; width: 100%; clear:both;margin:0;padding:0;"></div>

It does not hurt to add height: 100% to the container either, though this is iffy.

Marshall

[edited by: Marshall at 11:39 am (utc) on Sep. 7, 2007]

vanjustin

11:55 am on Sep 7, 2007 (gmt 0)

10+ Year Member



Hi Marshall,

Brilliant! your solution is effective I add height:100% to the content wrapper.

Thank you very much. This is a big help to me!:):):)

Marshall

12:55 pm on Sep 7, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



See, iffy is good. Glad to help.

Marshall