CSS——清除浮動

林堯彬發表於2020-04-04

 

<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;

}

轉載於:https://www.cnblogs.com/darknoll/p/4097684.html

相關文章