2012-06-24 158 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文件。