国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > CSS > 正文

詳細解讀CSS中的偽類after

2024-07-11 08:35:43
字體:
來源:轉載
供稿:網友

1. 引子

前段時間學習 web 布局的時候,因為要用浮動 float 屬性,所以就順理成章地碰到了清除浮動 clear 屬性。教學的案例中是用新建一個空的 div 標簽的方式來清除浮動的,主要代碼如下:

CSS Code復制內容到剪貼板

<div class="mainBox">   
    <div class="leftBox"></div>   
    <div class="rightBox"></div>   
    <div class="clear"></div>   
</div>   
  
.mainBox   
{   
    width:960px;   
    margin:0 auto;   
    background-color:#CFF;   
    overflow:visible;   
}   
.leftBox   
{   
    width:740px;   
    height:300px;   
    background-color:#C9F;   
    float:left;   
}   
.rightBox   
{   
    width:210px;   
    height:300px;   
    background-color:#FCF;   
    float:rightright;   
}   
.clear  
{   
    clear:both;   
    height:0;/*解決IE6下有高度的問題*/  
    overflow:hidden;   
}  

看到之后,想到以前見到過有用 css 偽類 after 來進行清除浮動的方式。記不太清了,于是寫成了如下的情況:

CSS Code復制內容到剪貼板

<div class="mainBox">   
    <div class="leftBox"></div>   
    <div class="rightBox"></div>   
</div>   
  
.mainBox{   
    width:960px;   
    background-color:#CFF;   
    margin:0 auto;   
    }   
.leftBox{   
    width:740px;   
    height:300px;   
    background-color:#C9F;   
    float:left;   
}   
.rightBox{   
    width:210px;   
    height:300px;   
    background-color:#FCF;   

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 柳林县| 隆化县| 本溪市| 正安县| 黄龙县| 栾城县| 曲松县| 武胜县| 南陵县| 镇赉县| 文水县| 治县。| 大宁县| 福鼎市| 德昌县| 托克逊县| 广德县| 牙克石市| 凤凰县| 嘉黎县| 陕西省| 南郑县| 鹰潭市| 辽阳市| 南开区| 大理市| 长乐市| 专栏| 巩义市| 库车县| 景宁| 垫江县| 鄂托克旗| 垫江县| 青川县| 定边县| 饶平县| 子长县| 淳化县| 溧水县| 大关县|