Is it possible to find CSS rules from an HTML node via JavaScript?

前端 未结 5 1289
深忆病人
深忆病人 2020-12-09 21:49

I want to get an element in the DOM and then lookup what rules in my CSS file(s) are contributing to it\'s appearance. Similar to what firebug or webkits inspector does. Is

5条回答
  •  我在风中等你
    2020-12-09 22:26

    Well, it's an old subject. Good for Webkit for offering a solution. As suggested, I've looked into firebug-lite and... surprise!! For every node it loops over every rule in every stylesheet checking if the selector matches our nodes or not.

提交回复
热议问题