我從來沒有使用條件之前(但知道我最終必須 - 我恨你IE)。基本上,我有使用CSS梯度在我的網站上的橫幅:使用條件CSS來顯示漸變圖像到IE
background-image: linear-gradient(bottom, #2B7BB8 44%, #4394CE 72%, #58A8E1 86%);
background-image: -o-linear-gradient(bottom, #2B7BB8 44%, #4394CE 72%, #58A8E1 86%);
background-image: -moz-linear-gradient(bottom, #2B7BB8 44%, #4394CE 72%, #58A8E1 86%);
background-image: -webkit-linear-gradient(bottom, #2B7BB8 44%, #4394CE 72%, #58A8E1 86%);
background-image: -ms-linear-gradient(bottom, #2B7BB8 44%, #4394CE 72%, #58A8E1 86%);
background-image: -webkit-gradient(
linear,
left bottom,
left top,
color-stop(0.44, #2B7BB8),
color-stop(0.72, #4394CE),
color-stop(0.86, #58A8E1)
);
所以我增加了一個條件語句來裝載我在GIMP準備IE所有版本梯度圖像:
<!--[if IE]> background-image:url('img/ieback.png'); <![endif]-->
<!--[if IE]> background-repeat:repeat-x; <![endif]-->
我的電腦上沒有IE瀏覽器(linux),因此我使用Adobe Browser Labs來測試我的網站在IE中的樣子。但是,圖像仍然無法加載。我的css的最終版本看起來像這樣:
background-image: linear-gradient(bottom, #2B7BB8 44%, #4394CE 72%, #58A8E1 86%);
background-image: -o-linear-gradient(bottom, #2B7BB8 44%, #4394CE 72%, #58A8E1 86%);
background-image: -moz-linear-gradient(bottom, #2B7BB8 44%, #4394CE 72%, #58A8E1 86%);
background-image: -webkit-linear-gradient(bottom, #2B7BB8 44%, #4394CE 72%, #58A8E1 86%);
background-image: -ms-linear-gradient(bottom, #2B7BB8 44%, #4394CE 72%, #58A8E1 86%);
background-image: -webkit-gradient(
linear,
left bottom,
left top,
color-stop(0.44, #2B7BB8),
color-stop(0.72, #4394CE),
color-stop(0.86, #58A8E1)
);
<!--[if IE]> background-image:url('img/ieback.png'); <![endif]-->
<!--[if IE]> background-repeat:repeat-x; <![endif]-->
我做錯了什麼?
IE10時被釋放,並支持CSS3漸變關於什麼的?使用功能檢測而不是瀏覽器檢測 – 2011-12-17 17:17:45
好的一點,我會改變它'如果lt IE9' – n0pe 2011-12-17 17:18:48
其實我查了它並且微軟正在刪除IE10中的條件註釋,並且IE9不支持漸變,所以你可以做'<! - [if IE] - >' – 2011-12-17 17:41:29