如果我循环遍历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
如何只查找样式表中实际设置的规则?