如何只获得样式表声明中声明的样式而不是计算样式?

时间:2014-09-10 20:24:03

标签: javascript css html5 css3

如果我循环遍历document.styleSheets以查找与.myClass匹配的css规则,则会获得比实际声明的样式值更多的样式值。

例如,使用此CSS:

.myClass { border: none; }

我会得到所有这些规则:

border: medium none
borderBottom: medium none
borderBottomColor: -moz-use-text-color
MozBorderBottomColors: none
borderBottomStyle: none
borderBottomWidth: medium
borderColor: -moz-use-text-color
borderImage: none
borderImageSource: none
borderImageSlice: 100% 100% 100% 100%
borderImageWidth: 1 1 1 1
borderImageOutset: 0 0 0 0
borderImageRepeat: stretch stretch
borderLeft: medium none
borderLeftColor: -moz-use-text-color
MozBorderLeftColors: none
borderLeftStyle: none
borderLeftWidth: medium
borderRight: medium none
borderRightColor: -moz-use-text-color
MozBorderRightColors: none
borderRightStyle: none
borderRightWidth: medium
borderStyle: none
borderTop: medium none
borderTopColor: -moz-use-text-color
MozBorderTopColors: none
borderTopStyle: none
borderTopWidth: medium
borderWidth: medium
color: rgb(200, 200, 200)
MozBorderImage: none

如何只查找样式表中实际设置的规则?

0 个答案:

没有答案