HTML+CSS SVG霓虹灯效果

核心思想是一串文字由4层组成

效果

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>SVG霓虹字</title>
    <style>
.text{
    font-size: 64px;
    font-weight: bold;
    text-transform: uppercase;/*小写变大写字母*/
    fill: none;/*字体的填充为空*/
    stroke-width: 2px;
    stroke-dasharray: 90 310;/*这两个属性需要慢慢理解*/
    animation: stroke 6s infinite linear;
}
.text-1{
    stroke: #3498db;
    text-shadow: 0 0 5px #3498db;
    animation-delay: -1.5s;
}
.text-2{
    stroke: #f39c12;
    text-shadow: 0 0 5px #f39c12;
    animation-delay: -3s;
}
.text-3{
    stroke: #e74c3c;
    text-shadow: 0 0 5px #e74c3c;
    animation-delay: -4.5s;
}
.text-4{
    stroke: #9b59b6;
    text-shadow: 0 0 5px #9b59b6;
    /* animation-delay: -6s; */
}

@keyframes stroke {
  to{
    stroke-dashoffset: -400;
  }
}
    </style>
</head>
<body>
    <svg width="100%" height="100">
        <text text-anchor="middle" x="50%" y="50%" class="text text-1">
            forever
        </text>
        <text text-anchor="middle" x="50%" y="50%" class="text text-2">
            forever
        </text>
        <text text-anchor="middle" x="50%" y="50%" class="text text-3">
            forever
        </text>
        <text text-anchor="middle" x="50%" y="50%" class="text text-4">
            forever
        </text>
    </svg>  
</body>
</html>
stroke-dasharray建议看这篇文章

stroke-dashoffset看这篇

这两篇搭配起来看会更好,但我估计也看不懂,可以多找找其他文献。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

Cwiyc

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

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

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

打赏作者

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

抵扣说明:

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

余额充值