<html>
<body>
<h1>Window 对象</h1>
<h2 id="test" style="background-color:lightblue">
getComputedStyle() 方法
</h2>
<p>测试元素的计算样式是:</p>
<p id="demo"></p>
<script>
const element = document.getElementById("test");
const cssObj = window.getComputedStyle(element, null);
let text = "";
for (x in cssObj) {
cssObjProp = cssObj.item(x)
text += cssObjProp + " = " + cssObj.getPropertyValue(cssObjProp) + "<br>";
}
document.getElementById("demo").innerHTML = text;
</script>
</body>
</html>