首页 > 开发 > CSS > 正文

浅谈CSS中的clear清除浮动

2024-07-11 08:32:53
字体:
来源:转载
供稿:网友

1、CSS中的clear有四个参数:

none:允许两边都可以浮动。

left:不允许左边有浮动。

right:不允许右边有浮动。

both(默认);不允许有浮动。

2、一开始在CSS中clear浮动是默认both,也就是说一开始不能有浮动的。

3、使用的案例:假设我清除第三个DIV的浮动

XML/HTML Code复制内容到剪贴板
  1. <style type="text/css">   div{   
  2. border:1px solid red;    float:left;   
  3. clear:none;    }   
  4. #msg_Div{    width:600px;   
  5. height:600px;    }   
  6. .one{    width:100px;   
  7. height:90px;    }   
  8. .two{    width:100px;   
  9. height:90px;    }   
  10. .three{    width:100px;   
  11. height:90px;    clear:left;   
  12. }    .four{   
  13. width:100px;    height:90px;   
  14. }    .five{   
  15. width:100px;    height:90px;   
  16. }    </style>  
  17.        
  18.    <body>  
  19. <div id="msg_Div">   <div class="one"></div>  
  20. <div class="two"></div>   <div class="three"></div>  
  21. <div class="four"></div>   <div class="five"></div>  
  22. </div>   </body>  

效果:

   

以上这篇浅谈CSS中的clear清除浮动就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持错新站长站。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表