老师麻烦帮忙看下,谢谢
来源: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回答
同学你好,效果实现是对的,建议:
1、样式相同的代码可以书写在一起,简化代码书写,示例:
2、同学代码中实现五角星的方式是可以的,老师给同学提供另一种实现的参考思路:
做出三个三角图形然后通过旋转角度最后通过定位把它们组合在一起,
三角形的实现思路如下:
当一个盒子宽高为0,只设置边框的时候,会发现边框是由四个小三角组成。
所以给其他角度的三角设置透明(transparent),然后只留一个即可实现一个三角形。参考如下小例子:
下方有个五角星的小例子,同学可以参考下:
效果:
最后将所有三角形的颜色换成统一的黄色就可以了
祝学习愉快~
相似问题
回答 1
回答 1
回答 1
回答 1
回答 2