When to use “!important” to save the day (when working with CSS)

前端 未结 7 1870
北海茫月
北海茫月 2020-12-04 02:10
#div p {
    color: red !important;
}
...
#div p {
    color: blue;
}

I understand how !important works, in this case the div will ren

7条回答
  •  半阙折子戏
    2020-12-04 02:11

    !important saves the day in cases where you dont control HTML output and it renders a style='' attribute. Think ASP.NET and other frameworks.

    The only way you can then change this styling is by either using javascript or marking your CSS rule as more !important.

提交回复
热议问题