用css 写一个红绿灯左转箭头
时间: 2023-08-04 14:23:28 浏览: 59
好的,以下是一个红绿灯左转箭头的 CSS 代码示例:
HTML 代码:
```
<div class="traffic-light">
<div class="arrow"></div>
<div class="red-light"></div>
<div class="yellow-light"></div>
<div class="green-light"></div>
</div>
```
CSS 代码:
```
.traffic-light {
position: relative;
width: 100px;
height: 220px;
}
.arrow {
position: absolute;
top: 90px;
left: -40px;
width: 0;
height: 0;
border-top: 30px solid transparent;
border-bottom: 30px solid transparent;
border-right: 40px solid #00ff00;
}
.red-light, .yellow-light, .green-light {
position: absolute;
border-radius: 50%;
width: 60px;
height: 60px;
left: 20px;
}
.red-light {
top: 20px;
background-color: red;
}
.yellow-light {
top: 90px;
background-color: yellow;
}
.green-light {
top: 160px;
background-color: green;
}
```
你可以将上述代码复制到一个 HTML 文件中,并在浏览器中查看效果。希望这能对你有所帮助!