IE 忽略 css 中的 !important 标签
最近我在 IE 中遇到了一个奇怪的事情。
它忽略 CSS 属性的“!important”标签。
除了直接将其作为 DOM 内的样式属性之外,是否有人有解决方法?
我不想进入 DOM 并将样式属性放入其中。
Recently I came across a wierd thing in IE.
It ignores a '!important' tag for CSS attributes.
Does anyone have a workaround for this, except putting it directly as a style attribute inside the DOM?
I do not want to go into the DOM and put styling attributes in it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现如果
!important
标签之前已在您尝试覆盖/更新的样式上使用过,则该标签将无法在该样式中工作。例如,如果您有:
并且,例如,如果您使用 媒体查询 并告诉样式在浏览器尺寸减小时更改:
辅助 colr
#fff
由于分配给颜色#ff0000
的!important
,因此不会生效。只是一个观察/想法。
很难猜测是什么导致了这个问题。为了让 SO 的用户真正为您提供帮助,您必须提供jsfiddle.net 或在问题中发布您的 HTML 和 CSS。
I've found the
!important
tag will not work in a style if it has previously been used on the style that you are trying to overwrite/update.For example, if you have:
And, say for example, if your using Media Queries and tell the style to change upon the browser being reduced in size:
The secondary colr
#fff
won't take affect because of the!important
assigned to the color#ff0000
.Just an observation/thought.
It's pretty hard to guess what is causing the issue. For the users of SO to really help you, you will have to either supply a live link, sample code on jsfiddle.net or post your HTML and CSS in the question.