views:

38

answers:

5

I'm working on a webpage (link text), but I'm having trouble with the height property in Google Chrome. If you view the page, you'll notice that there is no background color. This is because the #mainContent has a height of 0px. In Internet Explorer, this is not the case. Does anyone have ideas?

A: 

try explicitly defining the default

height:auto;

isildur4
+4  A: 

This is because the inner content is being floated. Parent elements do not take the height of floated children. Try adding overflow: hidden; to the #mainContent css.

Greg W
+4  A: 

Everything inside of #mainContent is floating. Floats don't make their container resize. The easiest solution is to add a clear right before then end of #mainContent like so:

<div id="mainContent">
<!-- inner bars -->
<div style="clear:both;"></div>
</div>
anq
This is a "hacky" solution (I'm sure there are more "semantic" ways), but it's the easiest and one of the most used. +1
Andreas Bonini
Absolutely right. I've never liked doing it because of the clutter but it's dead-easy and well supported.
anq
This one worked as well, but adding overflow: hidden to the CSS meant I didn't have to modify each page individually. Which I liked a little better.
Quenton Jones
+1  A: 

I have a feeling it will be something to do with the contents of the #mainContent div not pushing out the container properly. You should be able to fix this a number of different ways, such as using a clearing div.

Add the following css:

.clearfix{
    clear:both;
}

And add a div with the clearfix class before closing the maincontent div:

<div id="mainContent">
    <div id="rightSide">
     ...
    </div>
    <div id="content">
     ...
    </div>
    <div class="clearfix"/>
</div>

This should remind the browser to force open the mainContent div to fit its contents.

Blakomen
A: 

Haha, this will be a hard question for you to check as answered because there are a variety of ways to clear floats. (You can also try floating #mainContent as well)

Here's the wonderful quirksmode article.

attack