IE ignores !important tag in css [closed]

本小妞迷上赌 提交于 2019-12-10 02:37:44

问题


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.


回答1:


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:

.example{
color:#ff0000 !important;
}

And, say for example, if your using Media Queries and tell the style to change upon the browser being reduced in size:

.example{
color:#fff !important;
}

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.



来源:https://stackoverflow.com/questions/6126893/ie-ignores-important-tag-in-css

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!