javascript修改css属性
<!doctype<html><head><title>aaaaa</title><script>window.onload=border;functionborder(...
<!doctype <html> <head> <title>aaaaa</title> <script> window.onload=border;function border(){ var firsttriangle = document.getElementById("firsttriangle"); var border=document.body.clientWidth; firsttriangle.sytle.borderWidth='100px'+border+'0 0';} </script> <style> .sss{ width: 0; height: 0; border-style: solid; border-width: 100px 500px 0 0; border-color: #332dad transparent transparent transparent; } </style> </head> <body> <div class="sss"></div> </body></html>
怎么让'sss'的width等于屏幕宽度? 展开
怎么让'sss'的width等于屏幕宽度? 展开
2个回答
展开全部
<!DOCTYPE <html>
<html>
<head>
<title>aaaaa</title>
<script>
window.onload=border;
function border(){
var firsttriangle = document.getElementById("firsttriangle");
var border=document.body.clientWidth;
firsttriangle.style.borderWidth='100px '+border+' 0 0';
}
</script>
<style>
.sss{
width: 0;
height: 0;
border-style: solid;
border-width: 100px 500px 0 0;
border-color: #332dad transparent transparent transparent;
}
</style>
</head>
<body>
<div id="firsttriangle" class="sss"></div>
</body>
</html>
有两个地方你弄错了,第一个要 给 div 加一个id,第二个 firsttriangle.sytle,单词写错了,应该是 style
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询