CSS3 制作的彩虹条纹渐变文字

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="chrome=1">
    <title>CSS3 制作的彩虹条纹渐变文字</title>
    <style>
    html, body {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: black;
    }

    .rainbow {
    color: white;
    font-size: 300px;
    text-transform: uppercase;
    font-family: sans-serif;
    font-weight: bold;
    line-height: 1em;
    position: relative;
    }

    .rainbow span::before,
    .rainbow span::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    overflow: hidden;
    }

    .rainbow span:nth-child(1)::before {
    color: orchid;
    z-index: 1;
    height: calc(100% - 10% * 1);
    }

    .rainbow span:nth-child(1)::after {
    color: mediumpurple;
    z-index: 2;
    height: calc(100% - 10% * 2);
    }

    .rainbow span:nth-child(2)::before {
    color: deepskyblue;
    z-index: 3;
    height: calc(100% - 10% * 3);
    }

    .rainbow span:nth-child(2)::after {
    color: cyan;
    z-index: 4;
    height: calc(100% - 10% * 4);
    }

    .rainbow span:nth-child(3)::before {
    color: mediumspringgreen;
    z-index: 5;
    height: calc(100% - 10% * 5);
    }

    .rainbow span:nth-child(3)::after {
    color: yellow;
    z-index: 6;
    height: calc(100% - 10% * 6);
    }

    .rainbow span:nth-child(4)::before {
    color: gold;
    z-index: 7;
    height: calc(100% - 10% * 7);
    }

    .rainbow span:nth-child(4)::after {
    color: tomato;
    z-index: 8;
    height: calc(100% - 10% * 8);
    }

    .rainbow span::before,
    .rainbow span::after {
    animation: animate 0.8s infinite alternate;
    filter: opacity(0);
    }

    @keyframes animate {
    from {
        filter: opacity(0);
    }

    to {
        filter: opacity(1);
    }
    }
    .rainbow span:nth-child(1)::before {
    animation-delay: calc(0.8s - 0.1s * 1);
    }

    .rainbow span:nth-child(1)::after {
    animation-delay: calc(0.8s - 0.1s * 2);
    }

    .rainbow span:nth-child(2)::before {
    animation-delay: calc(0.8s - 0.1s * 3);
    }

    .rainbow span:nth-child(2)::after {
    animation-delay: calc(0.8s - 0.1s * 4);
    }

    .rainbow span:nth-child(3)::before {
    animation-delay: calc(0.8s - 0.1s * 5);
    }

    .rainbow span:nth-child(3)::after {
    animation-delay: calc(0.8s - 0.1s * 6);
    }

    .rainbow span:nth-child(4)::before {
    animation-delay: calc(0.8s - 0.1s * 7);
    }

    .rainbow span:nth-child(4)::after {
    animation-delay: calc(0.8s - 0.1s * 8);
    }

    .rainbow {
    color: transparent;
    }
    </style>
</head>
<body>
    <p class="rainbow">
        web
        <span data-text="web"></span>
        <span data-text="web"></span>
        <span data-text="web"></span>
        <span data-text="web"></span>
    </p>
</body>
</html>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值