简体   繁体   English

是否可以获得所有应用的样式而不仅仅是计算出的样式

[英]Is it possible to get all applied Styles and not just the computed

Lets say you have one stylesheet with the following declaration at the top: 假设您有一个样式表,顶部有以下声明:

a {color: black; color: rgba(255, 255, 255, 0.6)}

So if I run document.styleSheets[0].cssRules[0].cssText I get back 所以,如果我运行document.styleSheets[0].cssRules[0].cssText我会回来

a{color: rgba(255, 255, 255, 0.6)}

Is there any possibility to get all the styles and not just the computed? 有没有可能得到所有的风格,而不仅仅是计算?

No. cssText is actually an accessor, like innerHTML . 不, cssText实际上是一个访问器,就像innerHTML一样。 Which means, you cannot recover any rules that the browser has eliminated. 这意味着,您无法恢复浏览器已消除的任何规则。 Unless you manually parse the CSS file. 除非您手动解析CSS文件。 (...which I do not recommend. Why do you wanna do that anyway?) (...我不推荐。为什么你还想这样做?)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM