老师,这样写可以吗?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>2-9 编程练习</title>
<style>
/* 矩形div */
.flag {
width: 300px;
height: 200px;
background: red;
margin: 50px auto;
}
/* 五个div的样式 */
div {
width: 0;
height: 0;
border: 10px solid transparent;
border-top: 6px solid yellow;
border-bottom: none;
position: relative;
}
/* 每一个小div的两个伪元素样式 */
div::before,
div::after {
width: 0;
height: 0;
content: "";
border: 10px solid transparent;
position: absolute;
left: 0;
top: 0;
}
/* 前伪元素样式 */
div::before {
border-left: none;
border-right: 6px solid #ff0;
transform: translate(-2px, -13px) rotate(-20deg);
}
/* 后伪元素样式 */
div::after {
border-left: 6px solid yellow;
border-right: none;
transform: translate(-3px, -13px) rotate(17deg);
}
/* 最大的五角星 */
div:first-child {
top: 50px;
left: 50px;
transform: scale(3)
}
/* 以下是四个小的五角星样式 */
div:nth-child(2) {
left: 100px;
top: 15px;
transform: rotate(20deg);
}
div:nth-child(3) {
left: 125px;
top: 30px;
transform: rotate(-20deg);
}
div:nth-child(4) {
left: 123px;
top: 55px;
}
div:last-child {
left: 100px;
top: 75px;
transform: rotate(20deg);
}
</style>
</head>
<body>
<section class="flag">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</section>
</body>
</html>17
收起
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星