请更新:要求的是四个红色三角形组成的风车图形
时间: 2024-09-22 20:07:36 浏览: 41
如果你想将上面的示例更新为四个红色三角形组成风车,可以简单地添加两个额外的 `.windmill-blade` 元素,并把它们放在适当的位置。以下是更新后的HTML和CSS代码:
```html
<!DOCTYPE html>
<html lang="zh">
<head>
<style>
.windmill {
width: 0;
height: 0;
position: relative;
}
.windmill-blade {
content: "";
position: absolute;
background-color: red; /* 将所有叶片设置为红色 */
}
.windmill-blade.first-blade {
top: 50%;
left: 40%;
transform-origin: bottom center;
border-left: 33.3333px solid transparent;
border-right: 33.3333px solid transparent;
border-bottom: 66.6667px solid red;
}
.windmill-blade.second-blade {
top: 50%;
left: 50%;
transform-origin: top center;
border-top: 33.3333px solid transparent;
border-bottom: 66.6667px solid red;
}
.windmill-blade.third-blade {
top: 50%;
left: 60%;
transform-origin: bottom center;
border-left: 33.3333px solid transparent;
border-right: 33.3333px solid transparent;
border-top: 66.6667px solid red;
}
.windmill-blade.fourth-blade {
top: 50%;
left: 50%;
transform-origin: top center;
border-top: 33.3333px solid transparent;
border-bottom: 66.6667px solid red;
/* 为了形成风车的效果,这里将第二个叶片也复制一份 */
transform: rotate(-90deg);
margin-left: -33.3333px;
}
</style>
</head>
<body>
<div class="windmill">
<div class="windmill-blade first-blade"></div>
<div class="windmill-blade second-blade"></div>
<div class="windmill-blade third-blade"></div>
<div class="windmill-blade fourth-blade"></div>
</div>
</body>
</html>
```
这次我们新增了两个类 `.first-blade` 和 `.third-blade` 分别放置在风车的最左边和最右边,然后对`.fourth-blade` 进行旋转并偏移来模拟第二个叶片。
阅读全文