HTML+CSS 文字渐变色动画 流光溢彩字

under Website  Notes of Programming  tag html  css    Published on February 15th , 2022 at 05:37 pm

示例

流光溢彩字

源码

<div class="RainBowText">流光溢彩字</div>

<style>
    @supports (-webkit-transform: scale(0)) {
        .RainBowText {
            background-image: linear-gradient(to right, red, orange, yellow, green, yellow, orange, red, orange, yellow, green, yellow, orange, red);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            -webkit-background-size: 200% 100%;
            animation: bgp 5s infinite linear;
            font-size: 50px;
        }
    }
    
    @keyframes bgp {
        0% {
            background-position: 0 0;
        }
        100% {
            background-position: -100% 0;
        }
    }
</style>

资料

方法改编自 Tempta36

本页由 matcha 整理和发布,采用 知识共享署名4.0 国际许可协议进行许可,转载前请务必署名
  文章最后更新时间为:February 15th , 2022 at 09:57 am
分享到:Twitter  Weibo  Facebook