getComputedStyle
getComputedStyle:获取元素所有的样式
参数1:要获取样式的对象
参数2:伪元素,一般不传,默认为null
返回值:是样式对象
获取元素属性的特点:
1.可以获取行内 也可以获取行外
2.获取的是字符串,带单位
3.获取的元素为只读,不能修改
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style type="text/css">
#box{
width: 100px;
height: 100px;
background-color: pink;
border: 10px yellow solid;
margin: 100px;
}
#box::after