SVG文字线条填色动画特效

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>SVG文字线条填色动画特效</title>
    <style>
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            background: #121212;
            margin: 0;
            font-family: Arial, sans-serif;
            overflow: hidden;
        }

        .container {
            width: 100%;
            max-width: 800px;
            text-align: center;
        }

        .text-animation {
            width: 100%;
            height: auto;
        }

        .text-path {
            fill: none;
            stroke: #fff;
            stroke-width: 2;
            stroke-dasharray: 1000;
            stroke-dashoffset: 1000;
            animation: draw 4s ease-in-out forwards;
        }

        .text-fill {
            fill: none;
            stroke: none;
            opacity: 0;
            animation: fill 2s ease-in-out 3s forwards;
        }

        @keyframes draw {
            to {
                stroke-dashoffset: 0;
            }
        }

        @keyframes fill {
            to {
                opacity: 1;
                fill: url(#gradient);
            }
        }

        /* 插入的链接样式 */
        .custom-link {
            position: fixed;
            bottom: 20px;
            right: 20px;
            color: rgba(255,255,255,0.7);
            text-decoration: none;
            font-size: 14px;
            background: rgba(0,0,0,0.3);
            padding: 8px 15px;
            border-radius: 20px;
            transition: all 0.3s ease;
        }

        .custom-link:hover {
            color: white;
            background: rgba(0,0,0,0.5);
        }
    </style>
</head>
<body>
    <div class="container">
        <svg class="text-animation" viewBox="0 0 800 200">
            <defs>
                <linearGradient id="gradient" x1="0%" y1="0%" x2="100%" y2="0%">
                    <stop offset="0%" stop-color="#ff3366" />
                    <stop offset="25%" stop-color="#ff6633" />
                    <stop offset="50%" stop-color="#ffcc33" />
                    <stop offset="75%" stop-color="#33cc33" />
                    <stop offset="100%" stop-color="#3399ff" />
                </linearGradient>
            </defs>
            
            <path class="text-path" d="M50,100 Q150,50 250,100 T450,100 T650,100" />
            <path class="text-fill" d="M50,100 Q150,50 250,100 T450,100 T650,100" />
            
            <path class="text-path" d="M50,150 Q150,200 250,150 T450,150 T650,150" />
            <path class="text-fill" d="M50,150 Q150,200 250,150 T450,150 T650,150" />
            
            <text x="400" y="80" text-anchor="middle" font-size="60" fill="none" stroke="#fff" stroke-width="2" stroke-dasharray="1000" stroke-dashoffset="1000" style="animation: draw 4s ease-in-out forwards;">
                <tspan x="400" dy="0">SVG</tspan>
            </text>
            
            <text x="400" y="80" text-anchor="middle" font-size="60" fill="none" opacity="0" style="animation: fill 2s ease-in-out 3s forwards;">
                <tspan x="400" dy="0" fill="url(#gradient)">SVG</tspan>
            </text>
        </svg>
    </div>
    

</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值