.clear 萬能清除浮動

html body div.clear,
html body span.clear
{
     background: none;
     border: 0;
     clear: both;
     display: block;
     float: none;
     font-size: 0;
     margin: 0;
     padding: 0;
     overflow: hidden;
     visibility: hidden;
     width: 0;
     height: 0;
}

 

還有一種是html

.clearfix:after {
    content: "020";
    display: block;
    height: 0;
    clear: both;
}
.clearfix {
    zoom: 1;
}

這個是優化版的清除浮動的樣式,很值得推薦。優化

使用方法:經過在頁面中添加<div class=」clear」></div> 或 <span class=」clear」> </span>來清除頁面中的浮動。spa

相關文章
相關標籤/搜索