2016-08-20 18:11:39
.clearfix {
zoom: 1;
}
[參考閱讀]
* PPK: Clearing floats
* How To Clear Floats Without Structural Markup
* mezzoblue: Clearance
====================
附錄 什麼是hasLayout
(以下內容摘自CSS Mastery一書的中譯本《精通CSS 高級Web標準解決方案》第154頁,人民郵電出版社,2007)
IE使用Layout概念來控制元素的尺寸和位置。如果一個元素有Layout,它就有自身的尺寸和位置;如果沒有,它的尺寸和位置由最近的擁有佈局的祖先元素控制。
在默認情況下,擁有Layout的元素包括:
<html>, <body><table>, <tr>, <th>, <td><img><hr><input>, <button>, <select>, <textarea>, <fieldset>, <legend><iframe>, <embed>, <object>, <applet><marquee>
(註意,<p>和<div>默認不擁有Layout。)
凡是具有以下CSS屬性的元素,也會擁有佈局:
float: left|rightdisplay: inline-block width: any value other than 'auto'height: any value other than 'auto'zoom: any value other than 'normal' (IE專用屬性)writing-mode: tb-rl(IE專用屬性)overflow: hidden|scroll|auto(隻對IE 7及以上版本有效)overflow-x|-y: hidden|scroll|auto(隻對IE 7及以上版本有效)
hasLayout是IE特有的屬性,不是CSS屬性。可以用Javascript函數hasLayout查看一個元素是否擁有Layout。如果 有,這個函數就返回true;否則返回false。hasLayout是一個隻讀屬性,所以無法使用Javascript進行設置。
[參考閱讀]
* On having layout
(完)