CSS与if / then浏览器逻辑 [英] CSS with if/then browser logic
本文介绍了CSS与if / then浏览器逻辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
对于浏览器< IE7,我想使用某个样式属性,而对于其他浏览器,我想使用另一个。我可以使用单个css文件,或者我必须做,如果然后逻辑包括一个ie hack css文件?
For browsers < IE7, I want to use a certain style attribute, while for other browsers I'd like to use another. Can I do this using a single css file, or do I have to do if then logic to include an ie hack css file?
推荐答案
p>这里有一个例子,你可以包含一个特定于IE6的CSS来覆盖IE 6或更低版本的特定CSS类:
Here's an example how you can include an IE6-specific CSS to override specific CSS classes for IE 6 or lower:
<link rel="stylesheet" type="text/css" href="/css/screen.css" title="MySiteStyle" media="screen" />
<!--[if lte IE 6]>
<link rel="stylesheet" type="text/css" href="/css/screen-ie6.css" title="MySiteStyle" media="screen" />
<![endif]-->
或者,您可以在每个元素基础上这样做:
Alternatively, you can do it on per-element basis like this:
<!--[if (!IE) | (gt IE 6)]>
<div class="header">
<![endif]-->
<!--[if lte IE 6]>
<div class="ie6_header">
<![endif]-->
MSDN有一些关于 IE条件注释支持。
MSDN has some more details about IE Conditional Comments support.
这篇关于CSS与if / then浏览器逻辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文