交通信号灯,哈哈哈

在这里插入图片描述

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body {
            margin: 0px;
            background: #fca701;
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100vh;
        }
        
        .traffic-light {
            position: relative;
            background: #222;
            border-radius: 10px;
            padding: 16px;
            box-shadow: inset 0 0 0px 5px #2a2a2a;
        }
        
        .light-red,
        .light-yellow,
        .light-green {
            position: relative;
            margin: 16px;
            width: 100px;
            height: 100px;
            border-radius: 50%;
            background: repeating-linear-gradient(#333, #443 5px);
            animation-duration: 4s;
            animation-iteration-count: infinite;
            animation-timing-function: step-end;
        }
        
        .light-red {
            animation-name: lightUpRed;
        }
        
        .light-yellow {
            animation-name: lightUpYellow;
        }
        
        .light-green {
            animation-name: lightUpGreen;
        }
        
        @keyframes lightUpRed {
            0% {
                background: repeating-linear-gradient(#f00, #e00 5px);
                box-shadow: 0 0 40px #f00;
                z-index: 1;
            }
            35% {
                background: repeating-linear-gradient(#443, #333 5px);
                box-shadow: none;
                z-index: 0;
            }
        }
        
        @keyframes lightUpYellow {
            80% {
                background: repeating-linear-gradient(#fd0, #ec0 5px);
                box-shadow: 0 0 40px #fd0;
                z-index: 1;
            }
        }
        
        @keyframes lightUpGreen {
            35% {
                background: repeating-linear-gradient(#0d0, #0c0 5px);
                box-shadow: 0 0 40px #0d0;
                z-index: 1;
            }
            80% {
                background: repeating-linear-gradient(#443, #333 5px);
                box-shadow: none;
                z-index: 0;
            }
        }
        
        .protector {
            width: 100%;
            position: absolute;
            top: 25px;
            left: 50%;
            transform: translateX(-50%);
            border-right: solid 30px transparent;
            border-left: solid 30px transparent;
            border-top: solid 100px #191919;
            border-radius: 11px;
            z-index: -1;
        }
        
        .protector:nth-child(2) {
            top: 142px;
        }
        
        .protector:nth-child(3) {
            top: 257px;
        }
    </style>
</head>

<body>
    <div class="traffic-light">
        <div class="protector"></div>
        <div class="protector"></div>
        <div class="protector"></div>
        <div class="light-red"></div>
        <div class="light-yellow"></div>
        <div class="light-green"></div>
    </div>
</body>

</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值