條件hack
if條件共包含6種選擇方式:是否、大于、大于或等于、小于、小于或等于、非指定版本
(1)是否:
指定是否IE或IE某個版本。關(guān)鍵字:空
<!--[if IE 9]>
<![endif-->]
(2)大于:
選擇大于指定版本的IE版本。關(guān)鍵字:gt(greater than)
<!--[if gt IE 9]>
<![endif-->]
(3)大于或等于:
選擇大于或等于指定版本的IE版本。關(guān)鍵字:gte(greater than or equal)
<!--[if gte IE 9]>
<![endif-->]
(4)小于:
選擇小于指定版本的IE版本。關(guān)鍵字:lt(less than)
<!--[if lt IE9]>
<![endif-->]
(5)小于或等于:
選擇小于或等于指定版本的IE版本。關(guān)鍵字:lte(less than or equal)
<!--[if lte IE 9]>
<![end if-->]
(6)非指定版本:選擇除指定版本外的所有IE版本。關(guān)鍵字:!
<version>
目前的常用IE版本為6.0及以上,推薦酌情忽略低版本,把精力花在為使用高級瀏覽器
的用戶提供更好的體驗上
屬性hack
_:
選擇IE6及以下。連接線(中劃線)(-)亦可使用,為了避免與某些帶中劃線的屬性混淆,所以使用下劃線(_)更為合適。
*:
選擇IE7及以下。諸如:(+)與(#)之類的均可使用,不過業(yè)界對(*)的認知度更高
\9:
選擇IE6+
\0:
選擇IE8+和Opera15以下的瀏覽器
.test {
color: #c30;? ? ? ? ? /* For latest Firefox, chrome, Safari */
color: #090\0;? ? ? ? /* For Opera15- */
color: #00f\9;? ? ? ? /* For IE8+ */
*color: #f00;? ? ? ? /* For IE7 */
_color: #ff0;? ? ? ? /* For