码迷,mamicode.com
首页 > 其他好文 > 详细

3.浮动问题解决方案

时间:2018-05-06 13:41:40      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:nbsp   问题解决   zoom   osi   width   str   new   hid   style   

  <style>
    .bar{
      /*overflow:hidden;*/   
   /*BFC解决方案在没有position情况下使用;应为超出部分会隐藏*/
   /*BFC参考第二篇随笔*/
      border:1px solid blue;
    }
    .bar:after{
      content:"";
      display:block;
      clear:both;
    }
    .bar{
      zoom:1;  /*ie专有属性 清除浮动 ie6 ie7*/
    }
    .child{
      float:left;
      width:100px;
      height:100px;
      border:1px solid red;
    }
  </style>
 
  <div class="bar">
    <div class="child"></div>
    <div class="child"></div>
  </div>
 
总结:两种解决方案
  1.在父元素中加 overflow:hidden;但是在没有position情况下使用,因为超出部分会被隐藏;
  2.在父元素中加
    .bar:after{
        content:"";
       display:block;
        clear:both;
      }
    .bar{zoom:1;  /*ie专有属性 清除浮动 ie6 ie7*/}  

3.浮动问题解决方案

标签:nbsp   问题解决   zoom   osi   width   str   new   hid   style   

原文地址:https://www.cnblogs.com/stone5/p/8997689.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!