子级用css float浮动 而父级div没高度不能自适应高度

时间:2015-06-23 15:01:46   收藏:0   阅读:296

子级对象使用css float浮动 而父级div不能自适应高度。

 

对父级div标签闭合</div>前加一个clear清除浮动对象。

    <!DOCTYPE html> 
    <html> 
    <head> 
    <meta charset="utf-8" /> 
    <title>父div不自适应高度实例</title> 
    <style> 
    .divcss5{width:500px;border:1px solid #000;padding:10px} 
    .divcss5-lf{ float:left; width:220px; height:100px; background:#000} 
    .divcss5-rt{ float:right; width:230px; height:100px; background:#06F} 
    .clear{ clear:both} 
    </style> 
    </head> 
    <body> 
    <div class="divcss5"> 
    <div class="divcss5-lf"></div> 
    <div class="divcss5-rt"></div> 
    <div class="clear">对父级div标签闭合div前加一个clear清除浮动对象</div> 
    </div> 
    </body> 
    </html>

 

原文:http://www.cnblogs.com/ribavnu/p/4595280.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!