Demo
Using the clearfix technique is useful, but someone pointed out that the problem of using this method increases the add-on value as shown in the demo.
The height of both is equal.
CSS:
body{margin: 0; padding: 0;} #wrap{width: 900px; height: 250px; background: red; margin: 0 auto;} .clearfix:before, .clearfix:after{content: "."; display: table;} .clearfix:after{clear: both;} .clearfix{zoom: 1;} #box{float: left; width: 200px; height: 250px; background: blue;}
HTML:
<div id="wrap" class="clearfix"> <div id="box"><h1>some heading text here</h1></div> </div>
user2218109
source share