大数跨境
0
0

模拟红绿灯(可复制源代码)

模拟红绿灯(可复制源代码) 趣聊科技圈
2024-09-18
0

效果演示

html 代码

<link rel="stylesheet" href="index.css">
<div class="trafficlight">
  <div class="protector"></div>
  <div class="protector"></div>
  <div class="protector"></div>
  <div class="red"></div>
  <div class="yellow"></div>
  <div class="green"></div>
</div>

css 代码

html{backgroundlinear-gradient(#08f, #fff);padding40px;width170px;height100%;margin0 auto;}
.protector{background: transparent;width180px;height0;position: absolute;top20px;left: -35px;border-right: solid 30px transparent;border-left: solid 30px transparent;border-top: solid 90px #111;border-radius10px;z-index: -1;}
.protector:nth-child(2){top140px;}
.protector:nth-child(3){top260px;}
.trafficlight{background#222;background-imagelinear-gradient(transparent 2%, #111 2%, transparent 3%, #111 30%);width170px;height400px;border-radius10px;position: relative;border: solid 5px #333;}
.trafficlight:before{background#222;background-imageradial-gradient(#444, #000);content"";width170px;height150px;margin0 auto;position: absolute;top: -30px;margin-left0px;border-radius50%;z-index: -1;}
.trafficlight:after{background#222;background-imagelinear-gradient(-0deg, #444, #ccc 30%, #000);content"";width75px;height800px;margin-left50px;position: absolute;top150px;z-index: -1;}
.red{background: red;background-imageradial-gradient(brown, transparent);background-size5px 5pxwidth100px;height100px;border-radius50%;position: absolute;top20px;left35px;animation13s red infinite;box-shadow0 0 20px #111 inset,0 0 10px red;}
.yellow{background: yellow;background-imageradial-gradient(orange, transparent);background-size5px 5px;width100px;height100px;border-radius50%;position: absolute;top145px;left35px;animation13s yellow infinite;box-shadow0 0 20px #111 inset,0 0 10px yellow;}
.green{background: green;background-imageradial-gradient(lime, transparent);background-size5px 5px;width100px;height100px;border-radius50%;position: absolute;top270px;left35px;box-shadow0 0 20px #111 inset,0 0 10px lime;animation13s green infinite;}
@keyframes red{0%{opacity1;}20%{opacity1;}40%{opacity1;}60%{opacity: .1;}80%{opacity: .1;}100%{opacity: .1;}}
@keyframes yellow{0%{opacity: .1;}20%{opacity: .1;}40%{opacity1;}50%{opacity: .1;}60%{opacity: .1;}80%{opacity: .1;}100%{opacity: .1;}}
@keyframes green{0%{opacity: .1;}20%{opacity: .1;}40%{opacity: .1;}60%{opacity1;}80%{opacity1;}85%{opacity: .1;}90%{opacity1;}95%{opacity: .1;}100%{opacity1;}}


【声明】内容源于网络
0
0
趣聊科技圈
🧐探索科技,发现乐趣。🤩带你玩遍科技好物!
内容 511
粉丝 0
趣聊科技圈 🧐探索科技,发现乐趣。🤩带你玩遍科技好物!
总阅读63
粉丝0
内容511