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

前端 未结 5 1281
深忆病人
深忆病人 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:31

    A cross-browser solution I've had good success with is http://www.brothercake.com/site/resources/scripts/cssutilities/

    It is very powerful and accurate, derives a lot more information than the webkit-only function mentioned above, and it works on all styles (including those that are cross-site and that aren't active or have been overridden).

提交回复
热议问题