我有这些IE7的HTML条件代码,但它们似乎不起作用。
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="/css/stylesie.css" />
<![endif]-->
<link rel="stylesheet" type="text/css" href="/css/styles.css" />是不是出了什么问题,还是我漏掉了什么?
发布于 2012-03-17 23:40:20
如果你在stylesie.css中调整你的IE7规则,那么它应该在你的原始css文件之后加载:
<link rel="stylesheet" type="text/css" href="/css/styles.css" />
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="/css/stylesie.css" />
<![endif]-->具有相同specificity的选择器的规则将覆盖旧的规则,因此IE7将首先解析stylesie.css,并使用styles.css中的规则覆盖这些规则。
Basic example of this behavior:
div, div.red{
color:red;
}
div{
color:blue;
}这将导致除用类red标记的<div>之外的所有a都为蓝色。
发布于 2012-03-17 23:43:19
根据给定的信息,我只能尝试猜测:对我来说,看起来"/css/styles.css"覆盖了"/css/stylesie.css"的一些CSS属性,因为它包含在后面。因此,我会在此之前尝试将其包括在内:
<link rel="stylesheet" type="text/css" href="/css/styles.css" />
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="/css/stylesie.css" />
<![endif]-->发布于 2012-03-17 23:44:38
我猜你插入它的位置是问题所在。你的页面首先加载IE定义,然后添加你的CSS,它应该是所有浏览器的默认CSS。现在,如果有相同元素的定义,就像在IE版本中一样,这将简单地覆盖这些定义。
https://stackoverflow.com/questions/9751245
复制相似问题