Edit in JSFiddle


              
            
          
            
              
                
<div class="wrap clear"  >
    <h2>5) 父元素设置display:table </h2>
    <div class="box1 left">box1   float:left;</div>
    <div class="box2 left">box2   float:left;</div>
</div>
<div class="footer">.footer</div>
.clear{
   display:table; 
}
.box1{
    height:100px;
    background:#99FF33;
}
.box2{
    height:100px;
    background:#FF99FF;
}
.left{
    float:left;
}
.right{
    float:right;
}
.wrap{
    border:solid 1px black; 
}
.footer{
    background:lightblue;
}