老师请问这样做对不对?怎么做才是正确的,有完整代码吗?
来源:2-13 编程练习
weixin_慕码人7523200
2020-11-02 21:52:55
# 具体遇到的问题
# 报错信息的截图
# 相关课程内容截图
# 尝试过的解决思路和结果
# 粘贴全部相关代码,切记添加代码注释(请勿截图)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>五星红旗</title>
<style>
.red {
position: relative;
width: 600px;
height: 400px;
background-color: red;
margin: 100px auto;
}
.star1 {
position: absolute;
top: 80px;
left: 80px;
width: 0;
height: 0;
border: 50px solid transparent;
border-top-color: yellow;
}
.star1::before {
content: "";
position: absolute;
top: -71px;
left: -70px;
transform: rotateZ(66deg);
width: 0;
height: 0;
border: 50px solid transparent;
border-top-color: yellow;
}
.star1::after {
content: "";
position: absolute;
top: -93px;
left: -77px;
transform: rotateZ(134deg);
width: 0;
height: 0;
border: 50px solid transparent;
border-top-color: yellow;
}
.star2 {
position: absolute;
top: 20px;
left: 180px;
transform: scale(.5) rotateZ(35deg);
width: 0;
height: 0;
border: 50px solid transparent;
border-top-color: yellow;
}
.star2::before {
content: "";
position: absolute;
top: -71px;
left: -70px;
transform: rotateZ(66deg);
width: 0;
height: 0;
border: 50px solid transparent;
border-top-color: yellow;
}
.star2::after {
content: "";
position: absolute;
top: -93px;
left: -77px;
transform: rotateZ(134deg);
width: 0;
height: 0;
border: 50px solid transparent;
border-top-color: yellow;
}
.star3 {
position: absolute;
top: 55px;
left: 217px;
transform: scale(.5) rotateZ(75deg);
width: 0;
height: 0;
border: 50px solid transparent;
border-top-color: yellow;
}
.star3::before {
content: "";
position: absolute;
top: -71px;
left: -70px;
transform: rotateZ(66deg);
width: 0;
height: 0;
border: 50px solid transparent;
border-top-color: yellow;
}
.star3::after {
content: "";
position: absolute;
top: -93px;
left: -77px;
transform: rotateZ(134deg);
width: 0;
height: 0;
border: 50px solid transparent;
border-top-color: yellow;
}
.star4 {
position: absolute;
top: 108px;
left: 199px;
transform: scale(.5) rotateZ(75deg);
width: 0;
height: 0;
border: 50px solid transparent;
border-top-color: yellow;
}
.star4::before {
content: "";
position: absolute;
top: -71px;
left: -70px;
transform: rotateZ(66deg);
width: 0;
height: 0;
border: 50px solid transparent;
border-top-color: yellow;
}
.star4::after {
content: "";
position: absolute;
top: -93px;
left: -77px;
transform: rotateZ(134deg);
width: 0;
height: 0;
border: 50px solid transparent;
border-top-color: yellow;
}
.star5 {
position: absolute;
top: 150px;
left: 150px;
transform: scale(.5) rotateZ(75deg);
width: 0;
height: 0;
border: 50px solid transparent;
border-top-color: yellow;
}
.star5::before {
content: "";
position: absolute;
top: -71px;
left: -70px;
transform: rotateZ(66deg);
width: 0;
height: 0;
border: 50px solid transparent;
border-top-color: yellow;
}
.star5::after {
content: "";
position: absolute;
top: -93px;
left: -77px;
transform: rotateZ(134deg);
width: 0;
height: 0;
border: 50px solid transparent;
border-top-color: yellow;
}
</style>
</head>
<body>
<div class="red">
<div class="star1"></div>
<div class="star2"></div>
<div class="star3"></div>
<div class="star4"></div>
<div class="star5"></div>
</div>
</body>
</html>
1回答
同学你好,解答如下:
1、整体效果是可以的。如果再完善一下五角星的形状会更好。例如:
.star1 { position: absolute; width: 0; height: 0; top: 60px; border-left: 100px solid transparent; border-right: 100px solid transparent; border-bottom: 80px solid yellow; transform: rotate(35deg) scale(0.5); } .star1::before { content: ""; position: absolute; left: -100px; top: 0; width: 0; height: 0; border-left: 100px solid transparent; border-right: 100px solid transparent; border-bottom: 80px solid yellow; transform: rotate(-70deg); } .star1::after { content: ""; position: absolute; left: -63px; top: -47px; width: 0; height: 0; border-left: 30px solid transparent; border-right: 30px solid transparent; border-bottom: 80px solid yellow; transform: rotate(-35deg); }
2、编程题是没有完整代码的,因为代码很灵活,实现的方式不是唯一的。在学习阶段 , 鼓励大家先独立思考并完成效果 。做完之后存在疑惑的 ,可以在问答区域提问 ,老师会针对你的代码进行指导 , 这样能够了解同学具体哪里掌握的不好 ,有针对性的为你指导 。同学也能通过老师的指导,锻炼自己独立思考与编码的能力,才能更好的帮助你去成长 。
祝学习愉快~
相似问题