闪烁霓虹灯文字动画

效果图
在这里插入图片描述

源码示例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>闪烁霓虹灯文字动画</title>
    <style>
        /* cyrillic */
        @font-face {
            font-family: 'Bad Script';
            font-style: normal;
            font-weight: 400;
            src: url(https://fonts.gstatic.com/s/badscript/v16/6NUT8F6PJgbFWQn47_x7pO8kzO1A.woff2) format('woff2');
            unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
        }

        /* latin */
        @font-face {
            font-family: 'Bad Script';
            font-style: normal;
            font-weight: 400;
            src: url(https://fonts.gstatic.com/s/badscript/v16/6NUT8F6PJgbFWQn47_x7pOskzA.woff2) format('woff2');
            unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
        }

        body {
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            background-color: #000;
            font-family: 'Bad Script', cursive;
        }

        h1 {
            margin: 0;
            padding: 0;
            color: #111;
            font-size: 16em;
        }

        h1 span {
            display: table-cell;
            margin: 0;
            padding: 0;
            animation: animate 2s linear infinite;
            animation-delay: calc(var(--i)*0.25s);
        }

        @keyframes animate {

            0%,
            100% {
                color: #fff;
                filter: blur(2px);
                text-shadow: 0 0 10px #00b3ff,
                    0 0 10px #00b3ff,
                    0 0 20px #00b3ff,
                    0 0 40px #00b3ff,
                    0 0 80px #00b3ff,
                    0 0 120px #00b3ff,
                    0 0 200px #00b3ff,
                    0 0 300px #00b3ff,
                    0 0 400px #00b3ff;
            }

            5%,
            95% {
                color: #111;
                filter: blur(0px);
                text-shadow: none;
            }
        }
    </style>
</head>

<body>
    <h1 class="text-luminous">
    </h1>
    <Script>
        window.onload = () => {
            let strText = "stunning"
            strLuminous(strText);
            function strLuminous() {
                let luminousBox = document.getElementsByClassName("text-luminous")[0];
                var strList = arguments[0].slice("");
                for (let index = 0; index < strList.length; index++) {
                    var span = document.createElement('span');
                    span.style = '--i:' + index + ';';
                    span.innerHTML = strList[index];
                    luminousBox.appendChild(span);
                    luminousBox.style = 'background-color: #000;'
                }
            }
        };
    </Script>
</body>

</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Qayrup

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值