What does it mean when a CSS rule is grayed out in Chrome's element inspector?

后端 未结 8 2280
夕颜
夕颜 2020-11-28 20:08

I\'m inspecting an h2 element on a web page using Google Chrome\'s element inspector and some of the CSS rules--which appear to be applied--are grayed out. It

8条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-28 20:44

    It means that the rule has been inherited, but is not applicable to the selected element:

    http://code.google.com/chrome/devtools/docs/elements-styles.html#computed_style

    The pane contains only properties from rules that are directly applicable to the selected element. In order to additionally display inherited properties, enable the Show inherited checkbox. Such properties will be displayed in a dimmed font.

    greyed out rules are inherited from ancestors

    Live example: inspect the element containing the text "Hello, world!"

    div { 
      margin: 0;
    }
    
    div#foo { 
      margin-top: 10px; 
    }
    Hello, world!

提交回复
热议问题