What does it mean when Chrome Dev Tools shows a computed property greyed out

一个人想着一个人 提交于 2019-12-12 01:16:12

问题


Please note, not the Styles panel (I know what greyed-out means in that context—not applied), but the next panel over, the Computed properties panel.

What does it mean when a Computed property is shown greyed out?

Example:


回答1:


NB: This answer has no solid evidence, it's based on my observations along the time.

The gray calculated properties are neither default, nor inherited. This only occurs on properties that were not defined for the element, but calculated from either its children or parent based on runtime layout rendering.

Take this simple page as an example, display is default and font-size is inherited:

<style>
  div { font-size: 13px; }
</style>
<div>
  <p>asdf</p>
</div>

In this particular example, height is calculated from <p>'s children - text node (font size plus line height), width is calculated from its parent - <div>'s width, which is also calculated from its parent <body>.


EDIT: Well I thought again, here's my opinion based answer. I should really go and take a look at Chromium source code later :D

By expanding those arrows, you could see which actual rule is applied to the element, among all those defined against it (either directly or inherited, either by developer or browser):

Here you can trace down to every definition even including browser built-in rules, and check with the CSS cascading (overriding) mechanism.

So, for those elements that have no CSS definition (no directly defined, no inherited, no browser built-in), you don't have any source to trace. And the property values are totally runtime calculated.

If you check Show all, more grayed properties are shown. These are not defined anywhere either. But unlike those in previous screenshots, these are not runtime calculated - they are CSS spec default value.



来源:https://stackoverflow.com/questions/53928807/inspect-tool-elements-disabled

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