CSS !important does not override styles from external stylesheets

前端 未结 2 941
误落风尘
误落风尘 2021-01-01 18:46

In a stylesheet, I have this:

body {
  color: white !important;
}

Notice how it doesn\'t work on the text on the right side of this page:

2条回答
  •  别那么骄傲
    2021-01-01 19:28

    You have a more specific rule that is taking precedence on line 94 in main.css:

    #legend .label {
        color: black;
    }
    

    Change that to white and you are good to go.

    Regarding the important, it will take precedence over other references to body, but not to #legend label which is a more specific and applicable selector. Here is a decent article on specificity in CSS: http://css-tricks.com/specifics-on-css-specificity/

提交回复
热议问题