clear:both

 CSS中 clear:both;可以终结在出现他之前的浮动
  

语法: clear : none | left |right | both


参数:

none : 允许两边都可以有浮动对象

both : 不允许有浮动对象

left : 不允许左边有浮动对象

right : 不允许右边有浮动对象


说明: 该属性的值指出了不允许有浮动对象的边。请参阅float属性。 对应的脚本特性为clear


示例:

div { clear : left }

img { float: right }

<div style="clear:both;"></div>

主要是用在div套div的结构中。如果内div是浮动的,一般都需要clear浮动,不然的话内div会超出外div的框架

所用什么时候用clear:both;就很重要,一般我们在需要清除浮动的时候用到clear:both;不要轻意用到clear:both;因为它也有副伯用.

我们写一个clear:both;的例子:

<div style="float:left;width:100px;"> clear:both第1行第1列,</div>
<div style="float:left;width:700px;"> clear:both第1行第2列,</div>
<div style="clear:both;"> clear:both第2行。</div>


<div style="float:left;width:100px;"> 第1列,</div>
<div style="float:left;width:700px;"> 第2列,</div>
<div>第三列</div>
------------------------------------------------------------------------------------------------
<div style="float:left;width:100px;"> 第1列,</div>
<div style="float:left;width:700px;"> 第2列,</div>
<div style="clear:both;"></div>
<div>第三列</div>

 

参考:http://hi.baidu.com/keysarjan/blog/item/260e65397366a323b8998f01.html

posted @ 2009-02-06 13:20  BeamWen  阅读(1128)  评论(0编辑  收藏  举报