Why is the height of my div tag calculated as 0 in Chrome?

I am working on a webpage ( link text ), but I am having problems with the height property in Google Chrome. If you view the page, you will notice that the background color is missing. This is because #mainContent has a height of 0px. In Internet Explorer, this is not so. Does anyone have any ideas?

+5
source share
5 answers

This is due to the fact that the inner contents are floating. Parents do not occupy the height of floating children. Try adding overflow: hidden;to #mainContentcss.

+14
source

#mainContent . . , #mainContent :

<div id="mainContent">
<!-- inner bars -->
<div style="clear:both;"></div>
</div>
+8

, div #mainContent, . , , .

css:

.clearfix{
    clear:both;
}

div clearfix div maincontent:

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

, div mainContent .

+2

-, , , . ( #mainContent)

quirksmode.

+2

: ;

-2

All Articles