[英]css conditional formatting
I have the below code to check if the user are using IE7...and it needs to over ride the .web_info style. 我有以下代码来检查用户是否使用IE7 ......它需要超越.web_info样式。 If not IE7 it uses the default style, if its not IE at all it will use the ff_styles.css.
如果不是IE7它使用默认样式,如果它不是IE,它将使用ff_styles.css。 This doesnt seem to be working.
这似乎不起作用。
<link rel="stylesheet" type="text/css" href="../styles.css">
<![if !IE]>
<link rel="stylesheet" type="text/css" href="../ff_styles.css">
<![endif]>
<![if IE 7]>
<style type="text/css">
.web_info
{
left: 450px;
top: 200px;
width: 300px;
height: 60px;
}
</style>
<![endif]>
Any suggestions? 有什么建议么? Thanks
谢谢
Shouldn't this look like 不应该这样
<!--[if IE 7]>
..
<![endif]-->
and 和
<!--[if !IE]>
...
<![endif]-->
Note that 注意
<!--[if !IE]>
should never yield true as these Conditional comments only get interpreted by IE. 永远不应该产生真实,因为这些条件评论只能由IE解释。
Conditional comments are IE specific and therefore " <![if !IE]>
" is not a valid instruction for firefox or any other browser. 条件注释是IE特定的,因此“
<![if !IE]>
”不是firefox或任何其他浏览器的有效指令。 Additionally I would suggest you try the following syntax: 另外我建议你尝试以下语法:
<!--[if IE 7]>
<style type="text/css">
.web_info
{
left: 450px;
top: 200px;
width: 300px;
height: 60px;
}
</style>
<![endif]-->
One final note on my part: Since IE7/IE8 are mostly standard compliant, these CSS hacks should be avoided, if possible. 关于我的最后一个注意事项:由于IE7 / IE8主要是标准兼容的,如果可能的话,应该避免这些CSS黑客攻击。
Update: Thanks to slosd I stand corrected! 更新:感谢slosd我站得更正了! According to " Supporting IE with conditional comments " you can use the following to hide something from IE:
根据“ 使用条件注释支持IE ”,您可以使用以下内容隐藏IE中的内容:
<!--[if !IE]>-->
do something; IE will ignore this, other browsers parse it
<!--<![endif]-->
Sorry for the inconvenience I caused! 很抱歉给我带来的不便!
Full working example: 完整的工作示例:
<link rel="stylesheet" type="text/css" href="../styles.css">
<!--[if !IE]>-->
<link rel="stylesheet" type="text/css" href="../ff_styles.css">
<!--<![endif]-->
<!--[if IE 7]>
<style type="text/css">
.web_info{
left: 450px;
top: 200px;
width: 300px;
height: 60px;
}
</style>
<![endif]-->
Don't check if the browser is not IE, check if it is IE7 then if it is IE and then fallback for default. 不要检查浏览器是否不是IE,检查它是否是IE7然后是否是IE,然后默认为回退。 More info: http://www.quirksmode.org/css/condcom.html
更多信息: http : //www.quirksmode.org/css/condcom.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.