2012-06-24 157 views
-3

的文件/網頁內容下面連接的外部級聯樣式表條件CSS聲明

<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Untitled Document</title> 
<link href="css/a.css" rel="stylesheet" type="text/css" /> 
<link href="css/b.css" rel="stylesheet" type="text/css" /> 
<link href="css/c.css" rel="stylesheet" type="text/css" /> 
<link href="css/d.css" rel="stylesheet" type="text/css" /> 
</head> 

如果我想使用多個瀏覽器的a.css特定條件語句只有在所有的樣式表,其他的怎麼樣像b.css,c.css和d.css這樣的樣式表應該放在head標籤中?

感謝,像這樣

+0

使用條件註釋。檢查類似的問題在這裏:http://stackoverflow.com/questions/3141992/if-ie-then-include-file-a-else-include-file-b。也在這裏:http://stackoverflow.com/questions/414738/using-conditional-comments-in-html –

回答

0

使用條件評論...

<!--if [browser-specific condition statement/s]> 
<link href="css/a.css" rel="stylesheet" type="text/css" /> 
<![endif]--> 

注入條件,根據您的需要。

+0

我知道這一點。我的問題是其他外部CSS文件在head標籤內的位置? –

+0

答案是肯定的。只需注入條件註釋,包裝你想要實現的任何CSS。 Fyi,條件註釋可以放在整個HTML文檔中的任何地方。 –

+0

在你做出第一個合理的答案之前,你不會仔細閱讀我的問題。甚至不是現在。此條件語句忽略其他css文件。我的問題是如何將條件限制在不影響其他css文件的不同瀏覽器之間。 –

0

答案可能是簡單的

<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Untitled Document</title> 
<link href="css/a.css" rel="stylesheet" type="text/css" /> 
<!--[if IE ]> 
<link href="/css/[email protected]" rel="stylesheet" type="text/css"> 
<![endif]--> 
<link href="/css/[email protected]" media="screen and (-webkit-min-device-pixel-ratio:0)" rel="stylesheet" type="text/css" /> 
....and so on 
// Other external css files shall go below this line within the head tag 
<link href="css/b.css" rel="stylesheet" type="text/css" /> 
<link href="css/c.css" rel="stylesheet" type="text/css" /> 
<link href="css/d.css" rel="stylesheet" type="text/css" /> 
</head> 

對於一些未知的原因我的本地主機上的瀏覽器都忽略了下面的條件註釋這是不是可數在所有的正確答案,其他的CSS文件。