获取伪元素样式值 [英] Getting pseudo-element style values

查看:93
本文介绍了获取伪元素样式值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与此问题相关通过JavaScript更改CSS伪元素样式,有什么方法使用javascript,我可以访问伪元素的样式属性?

Related to this question Changing CSS pseudo-element styles via JavaScript, is there any way using javascript that I can access a pseudo-element's style attributes?

推荐答案

这取决于浏览器。我不相信IE以任何方式支持这一点,但对于FireFox和Webkit浏览器,您可以使用以下:

It depends on the browser. I don't believe IE support this in any way, but for FireFox and Webkit browsers, you can use the following:

window.getComputedStyle(element, pseudo-selector);

例如:

window.getComputedStyle(document.body, ':before');

请参阅: getComputedStyle

这篇关于获取伪元素样式值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆