以下获取的值不对啊<!DOCTYPE html><html><head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta http-equiv="X-UA-Compatible" content="ie=edge" /><title>Document</title><style>#box{width: 100px;height: 100px;background: blue;}#box:before{content: ''; width: 0; height: 0; border-bottom: 100px solid red; border-right: 100px solid transparent;}</style></head><body><div id="box"></div><script>var box=document.getElementById("box");var s=document.defaultView.getComputedStyle(box,":after");console.log(s.borderRight)//"0px none rgb(0, 0, 0)"</script></body></html>
1 回答
产品经理不是经理
TA贡献481条经验 获得超143个赞
var s=document.defaultView.getComputedStyle(box,":after");这里你怎么用的是:after,前面不是before吗?改成:before就可以了啊。
添加回答
举报
0/150
提交
取消