<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
body {
font-family: "Microsoft YaHei", serif;
}
body, dl, dd, p, h1, h2, h3, h4, h5, h6 {
margin: 0;
}
ol, ul, li {
margin: 0;
padding: 0;
list-style: none;
}
img {
border: none
}
#wrap{
width: 200px;
height: 200px;
background-color: #cc3366;
}
</style>
</head>
<body>
<div id="wrap"></div>
<script>
// 除了行内样式我们都获取不到
// 写在style中的样式我们获取不到
// 所以我们直接获取元素最终显示出来的样式
let oWrap = document.getElementById("wrap");
// 我们直接使用getComputedStyle(oWrap)获取的是一个对象
console.log(getComputedStyle(oWrap).width);
console.log(getComputedStyle(oWrap).height);
console.log(getComputedStyle(oWrap).backgroundColor);
// 低版本ie需要使用另一个
// var oWrap = document.getElementById("wrap");
// console.log(oWrap.currentStyle);
// 兼容
// function f(node) {
// return node.currentStyle || getComputedStyle(node);
// }
// 如果做兼容的时候getComputedStyle报错的话
// 因为他是一个window下的属性 直接用window.getComputedStyle 如果不成就会报undefined
</script>
</body>
</html>
Python3Turtle