IE7 CSS继承不工作 [英] IE7 CSS inheritance does not work
问题描述
我为h2标签设置了一些样式(颜色,字体大小等),但是当我把A标签放在里面时,样式就变成了链接。我的html:
I have set some style for h2 tags (color, font-size, etc.), but when I put "A" tag inside, then style becomes as link. My html:
<h2>
<a class="no-decor" href="http://localhost/xxx/">Link</a>
</h2>
所以,你可以看到,我创建了无装饰类。它应该继承h2的a标签的样式。
So, as You can see, I've created "no-decor" class. It should inherit h2's style for "a" tag.
a.no-decor {
color:inherit;
font-family:inherit;
font-size:inherit;
font-weight:inherit;
text-decoration:inherit;
}
在Firefox上,everythig确定,但IE仍然显示标签a下划线文本装饰和蓝色)。我知道,我可以设置一些风格为h2 a,但也许不知何故可以强制工作CSS继承值在IE7?
On Firefox everythig is ok, but IE still shows tag "a" style (underline text-decoration and blue color). I know, I can set some style for "h2 a", but maybe somehow it is possible to force work CSS inherit values on IE7?
P.S。在IE6也不支持。
P.S. On IE6 doesn't supports too.
P.P.S。有一些相同的示例: http://www.brunildo.org/test/inherit。 html
P.P.S. There is some example in same way: http://www.brunildo.org/test/inherit.html
推荐答案
不,IE从不支持 inherit
任何财产 - 对不起。这已修复在> = IE8。
No, IE has never supported inherit
for any property - sorry. This has been fixed in >= IE8.
虽然您可以使用JavaScript修复程序从 h2
到 a
,可能最简单的方法是对两个元素应用相同的样式规则:
Whilst you could use a JavaScript fix to copy the properties from h2
to a
, it's probably easiest just to apply the same styling rule to both elements:
h2, h2 a {
font: something;
color: black;
text-decoration: none;
}
您不需要设置 code>对文本装饰,因为装饰不从父继承到孩子:下划线效果是在父和去通过孩子;孩子不能删除它(模数IE错误)。 'text-decoration:none'对孩子是正确的,除非你想潜在的两个下划线...
You don't need to set inherit
on text-decoration anyway, because decoration doesn't inherit from a parent into a child: the underline effect is on the parent and goes through the child; the child cannot remove it (modulo IE bugs). 'text-decoration: none' on the child is the right thing, unless you want potentially two underlines...
这篇关于IE7 CSS继承不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!