获取css规则
var styleSheets = document.styleSheets; for (var i = 0; i < styleSheets.length; ++i) { var cssRules = styleSheets[i].cssRules || styleSheets[i].rules;//获取某个style元素中所有规则集 for (var j = 0; j < cssRules.length; ++j) { var cssRule = cssRules[j];//获取某个规则集 console.info(cssRule.selectorText + " {");//获取该规则集的选择器 for (var k = 0; k < cssRule.style.length; ++k) { var propertyName = cssRule.style[k];//获取属性名 var propertyValue = cssRule.style[propertyName];//获取属性值 console.info(propertyName + ":" + propertyValue); } console.info("}"); } }