DIV CSS 佈局教程網

您现在的位置: DIV+CSS佈局教程網 >> 網頁腳本 >  >> CSS入門知識 >> DIV十CSS布局 >> 布局實例
clearfix 清除浮動通用寫法
編輯:布局實例     

清除浮動是 CSS 版面中非常常見的需求。clearfix 是一種不需額外 HTML 結構的通用做法。

clearfix 寫法

.clearfix:after {
  content: ".";
  display: block;
  height: 0;
  clear: both;
  visibility: hidden;
}
* html .clearfix {
  height: 1%;
}

簡易清除元素

.clear {
  clear: both;
  height: 0;
  overflow: hidden;
}

若父元素內含浮動子元素,加上 clearfix 可避免父元素高度塌陷。

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved