0

我有三個樣式表;一個用於IE7,一個用於IE8,另一個用於IE9 +/Firefox/Chrome。IE中的基本條件語句

我想使用條件語句將其中每個鏈接到我的文檔。我寫這些語句:

<!--[if IE 8]> 
    <link type="text/css" href="ie8.css" rel="stylesheet"/> 
<![endif]--> 
<!--[if IE 7]> 
    <link type="text/css" href="ie7.css" rel="stylesheet"/> 
<![endif]--> 
<!--[if ?????]> 
    <link type="text/css" href="style.css" rel="stylesheet"/> 
<![endif]--> 

我不確定最終條件的if聲明寫什麼。我需要像這樣:

<!--[if IE 9+ | !IE> 

這將意味着IF IE9+ or NOT IE

使用條件可以實現嗎?

回答

1
<!--[if gt IE 8]> 
    <link rel="stylesheet" type="text/css" href="ie9-and-up.css" /> 
<![endif]--> 

<!--[if gte IE 9]> 
    <link rel="stylesheet" type="text/css" href="ie9-and-up.css" /> 
<![endif]--> 

gt指 「大於」,gte指 「大於或等於」。

編輯

IE Conditional operator: OR ... if is greater than ie9 or not IE

<!--[if gte IE 9 | !IE ]><!--> 
    <link rel="stylesheet" type="text/css" href="ie9-and-up.css" /> 
<![endif]--> 
+0

謝謝,但是從測試這一點,似乎並沒有在Firefox上運行。獲取IE 9只在IE上註冊;我需要一些適用於Firefox的條件。 –

+0

嘗試僅使用大於8的解決方案的第一部分,並且支持'gt IE 8' – 4dgaurav

1

找到了答案:

<!--[if IE 8]> 
    // ie 8 stuff 
<![endif]--> 
<!--[if IE 7]> 
    // ie 7 stuff 
<![endif]--> 

<!--[if !(IE)]><!--> i am not ie <!--<![endif]-->