关于五角星的问题
来源:2-13 编程练习
慕盖茨3062073
2021-05-26 14:48:56
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=>, initial-scale=1.0">
<title>Document</title>
<style type="text/css">
*{
margin:0;
padding:0;
}
.background{
width:600px;问题描述:
height:400px;
background-color:red;
perspective:300px;
margin:100px auto;
/*position:relative;*/
}
.star{
width:0;
height:0;
position:relative;
top:50px;
left:20px;
border-right:50px solid transparent;
border-bottom:35px solid yellow;
border-left:50px solid transparent;
transform:rotate(35deg);
}
.star::before{
width:0;
height:0;
display:block;
position:absolute;
border-right:50px solid transparent;
border-bottom:35px solid yellow;
border-left:50px solid transparent;
transform:rotate(289deg);
top:-1px;
left:-49px;
content:'';
}
.star::after{
width:0;
height:0;
display:block;
position:absolute;
border-right:50px solid transparent;
border-bottom:35px solid yellow;
border-left:50px solid transparent;
transform:rotate(216deg);
top:2px;
left:-50px;
content:'';
}
.star1{
transform: translateX(0) translateY(48px);
}
.star2{
transform: translateX(82) translateY(-34px) rotate(-10deg) scale(0.4);
}
.star3{
transform: translateX(117) translateY(-34px) rotate(0deg) scale(0.4);
}
.star4{
transform: translateX(115) translateY(-19px) rotate(36deg) scale(0.4);
}
.star5{
transform: translateX(81) translateY(-21px) rotate(0deg) scale(0.4);
}
</style>
</head>
<body>
<div class="background">
<div class="star star1"></div>
<div class="star star2"></div>
<div class="star star3"></div>
<div class="star star4"></div>
<div class="star star5"></div>
</div>
</body>
</html>
老师我这个代码问题出在哪啊?star1,star2,star3,star4,star5属性不管用
1回答
好帮手慕然然
2021-05-26
同学你好,原因如下:css代码中设置水平位移时,数值后缺少px单位,如图:
另外,css代码中存在文字注释,建议注释一下,如图
祝学习愉快!
相似问题