老师麻烦帮忙看下,谢谢

来源:2-13 编程练习

咸鱼王派大星

2021-03-09 11:37:26

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.guoqi{
width: 300px;
height: 200px;
background-color: red;
background-position: center center;
perspective: 300px;
}
.wjx1{
width: 60px;
height: 40px;
transform: translateX(20px) translateY(5px);
}
.wjx1::before{
content: '★';
color: yellow;
font-size: 60px;
}
.wjx2{
width: 60px;
height: 40px;
transform: rotateZ(20deg) translateX(60px) translateY(-50px);
}
.wjx2::before{
content: '★';
color: yellow;
font-size: 20px;
}
.wjx3{
width: 60px;
height: 40px;
transform: rotateZ(40deg) translateX(40px) translateY(-90px);
}
.wjx3::before{
content: '★';
color: yellow;
font-size: 20px;
}
.wjx4{
width: 60px;
height: 40px;
transform: rotateZ(60deg) translateX(-5px) translateY(-95px);
}
.wjx4::before{
content: '★';
color: yellow;
font-size: 20px;
}
.wjx5{
width: 60px;
height: 40px;
transform: rotateZ(85deg) translateX(-65px) translateY(-55px);
}
.wjx5::before{
content: '★';
color: yellow;
font-size: 20px;
}
</style>
</head>
<body>
<section>
<div class="guoqi">
<div class="wjx1"></div>
<div class="wjx2"></div>
<div class="wjx3"></div>
<div class="wjx4"></div>
<div class="wjx5"></div>
</div>
</section>
</body>
</html>


写回答

1回答

好帮手慕慕子

2021-03-09

同学你好,效果实现是对的,建议:

1、样式相同的代码可以书写在一起,简化代码书写,示例:

http://img.mukewang.com/climg/60470b8d0929f40303890324.jpg

http://img.mukewang.com/climg/60470ba90948413e07820805.jpg

http://img.mukewang.com/climg/60470bb5093e38fd07710358.jpg

2、同学代码中实现五角星的方式是可以的,老师给同学提供另一种实现的参考思路:

做出三个三角图形然后通过旋转角度最后通过定位把它们组合在一起,

三角形的实现思路如下:

当一个盒子宽高为0,只设置边框的时候,会发现边框是由四个小三角组成。

http://img.mukewang.com/climg/5f0142de09ef92cf00850080.jpg

所以给其他角度的三角设置透明(transparent),然后只留一个即可实现一个三角形。参考如下小例子:

http://img.mukewang.com/climg/5fca178c090fc22d09230451.jpg

下方有个五角星的小例子,同学可以参考下:

http://img.mukewang.com/climg/5fca17a409dd8a2903770099.jpg

http://img.mukewang.com/climg/5fca17af090f42c406370749.jpg

http://img.mukewang.com/climg/5fca17b909d9f4e005970419.jpg

效果:

http://img.mukewang.com/climg/5f0144aa096b8d5102980242.jpg

最后将所有三角形的颜色换成统一的黄色就可以了

祝学习愉快~

1

0 学习 · 15276 问题

查看课程