删除/重置 CSS 行为属性
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4513738/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Remove/reset CSS behavior property
提问by Jeremy Kauffman
Is it possible to remove the IE-specific behavior CSS property via a more specific rule or the !important
declaration? Example:
是否可以通过更具体的规则或!important
声明删除特定于 IE 的行为 CSS 属性?例子:
.a-rule
{
behavior: url(/some.htc);
}
.a-rule.more-specific
{
behavior: /*no HTC*/
}
I realize that overriding CSS properties is undesirable, but I'm stuck here.
我意识到覆盖 CSS 属性是不可取的,但我被困在这里。
On Edit: I'm not sure where people are getting confused about this question. For all purposes, you can consider this already being an IE specific stylesheet. I'm asking how, if .a-rule
above exists and is immutable, how can one remove the behavior via a more specific rule? A standard CSS equivalent would be:
关于编辑:我不确定人们在哪里对这个问题感到困惑。出于所有目的,您可以认为这已经是 IE 特定的样式表。我在问如何,如果.a-rule
上述存在并且是不可变的,如何通过更具体的规则删除行为?标准的 CSS 等效项是:
.a-rule
{
border: 1px solid black;
}
.a-rule.more-specific
{
border: 0 none;
}
One can reset the border property for a subset of elements via a more specific rule. I'm asking how to reset the behavior property in an analogous way.
可以通过更具体的规则重置元素子集的边框属性。我在问如何以类似的方式重置行为属性。
回答by Jeremy Kauffman
The default value is "none". See:
默认值为“无”。看:
What is the *correct* way to unset the behavior property in CSS?
The solution:
解决方案:
.a-rule
{
behavior: url(/some.htc);
}
.a-rule.more-specific
{
behavior: none;
}
回答by haha
.a_rule {
border: 1px solid black; /* we know border is black */
behavior: url(/some.htc) /* we know something happen inside some.htc */
}
.a_rule.more-specific {
border: 0 none; /* we remove the border */
behavior: url(/some.htc) /* we remove something inside some.htc */
}
use different .htc
file
使用不同的.htc
文件
回答by Cole
Maybe use conditional tags for IE in your head
也许在你的脑海中为 IE 使用条件标签
<!--[if IE]>
<style type="text/css">
.a-rule {
behavior: url(/some.htc);
}
</style>
<![endif]-->