首页 > 代码库 > CSS——清除浮动

CSS——清除浮动

 

<div id="main" class="clear">

  <div id="left">

  </div>

  

  <div id="right">

  </div>

</div>

 

<div id="other">

</div>

/*-----------------------------------------------*/

#main{

backgroud-color:#aaa;

padding:10px;

}

#left{

background-color:#bbb;

padding:5px;

border:1px solid red;

width:100px;

height:100px;

float:left;

}

#right{

background-color:#ccc;

padding:5px;

border:1px solid red;

width:100px;

height:100px;

float:left;

border:1px solid red;

float:right;

}

 

.clear:after{

 content:".";

height:0;

visibility:hidden;

display:both;

clear:both;

}

CSS——清除浮动