用html和css实现字体发光效果

css部分:

 *{
            /* 页面内外边距初始化 */
            margin: 0;
            padding: 0;
        }
        .text{
            /* 100%的窗口高度 */
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            background-color: slateblue;
        }
        span{
            font-size:100px;
            font-weight: 700;
            color:yellow;
            /* 转换为大写 */
            text-transform: uppercase;
            /* 字间距 */
            letter-spacing: 6px;
            /* 模糊滤镜 */
            filter: blur(2px);
            /* 执行动画 */
         animation:trans  3s linear infinite;
        }
      
        /* 定义动画 */
        @keyframes trans{
            0%,100%{
               color: yellow;
               filter: blur(2px);
               /* 文字阴影 */
               text-shadow:
               0 0 10px  lightgreen,
               0 0 20px  lightgreen,
               0 0 30px  lightgreen,
               0 0 40px  lightgreen,
               0 0 100px  lightgreen,
               0 0 200px  lightgreen,
               0 0 300px  lightgreen,
               0 0 400px  lightgreen;
            }
            5%,95%{
                color:skyblue;
                filter: blur(0px);
                text-shadow: none;
            }
        }
        /* 为每一个span标签设置动画延迟时间 */
        span:nth-child(1){
            animation-delay: 0s;
        }
        span:nth-child(2){
            animation-delay: 0.6s;
        }
        span:nth-child(3){
            animation-delay: 1.2s;
        }
        span:nth-child(4){
            animation-delay: 1.8s;
        }
        span:nth-child(5){
            animation-delay: 2.4s;
        }
        span:nth-child(6){
            animation-delay: 3.0s;
        }

html部分:

 <div class="text">
        <span>h</span>
        <span>i</span>
        <span>w</span>
        <span>e</span>
        <span>b</span>
    </div>

页面效果图:

 

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值