jQuery波浪文字动画特效

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>jQuery波浪文字动画特效</title>
    <style>
        body {
            background: linear-gradient(135deg, #1a1a2e, #16213e);
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            font-family: 'Arial', sans-serif;
            overflow: hidden;
        }
        
        .wave-container {
            text-align: center;
            position: relative;
        }
        
        .wave-text {
            font-size: 4rem;
            font-weight: bold;
            color: #fff;
            text-shadow: 0 0 10px rgba(255,255,255,0.3);
            display: inline-block;
            margin-bottom: 30px;
        }
        
        .wave-text span {
            display: inline-block;
            position: relative;
            transition: all 0.3s ease;
        }
        
        .credit {
            position: absolute;
            bottom: 20px;
            right: 20px;
            color: rgba(255,255,255,0.5);
            font-size: 12px;
        }
        
        /* 插入的链接样式 */
        .inserted-link {
            color: #4facfe;
            text-decoration: none;
            font-size: 14px;
            position: absolute;
            top: 20px;
            right: 20px;
            transition: all 0.3s ease;
        }
        
        .inserted-link:hover {
            color: #00f2fe;
            text-shadow: 0 0 10px rgba(0, 242, 254, 0.5);
        }
        
        /* 波浪动画 */
        @keyframes wave {
            0% { transform: translateY(0) rotate(0deg); }
            25% { transform: translateY(-15px) rotate(5deg); }
            50% { transform: translateY(0) rotate(0deg); }
            75% { transform: translateY(10px) rotate(-5deg); }
            100% { transform: translateY(0) rotate(0deg); }
        }
    </style>
</head>
<body>
    <div class="wave-container">
        <div class="wave-text" id="waveText">jQuery波浪文字特效</div>
        
    </div>
    
    <div class="credit">动画效果使用jQuery实现</div>

    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script>
        $(document).ready(function() {
            // 将文本拆分为单个字符
            var text = $('#waveText').text();
            $('#waveText').empty();
            
            // 为每个字符创建span元素
            for (var i = 0; i < text.length; i++) {
                var char = text.charAt(i);
                if (char === ' ') {
                    char = '&nbsp;';
                }
                var $span = $('<span>').html(char);
                
                // 设置不同的颜色
                var hue = (i * 30) % 360;
                $span.css('color', 'hsl(' + hue + ', 100%, 70%)');
                
                $('#waveText').append($span);
            }
            
            // 为每个字符添加波浪动画
            $('#waveText span').each(function(index) {
                $(this).css({
                    'animation': 'wave 2s ease-in-out infinite',
                    'animation-delay': (index * 0.1) + 's',
                    'display': 'inline-block'
                });
                
                // 添加鼠标悬停效果
                $(this).hover(
                    function() {
                        $(this).css({
                            'transform': 'scale(1.2)',
                            'text-shadow': '0 0 15px rgba(255,255,255,0.7)'
                        });
                    },
                    function() {
                        $(this).css({
                            'transform': 'scale(1)',
                            'text-shadow': 'none'
                        });
                    }
                );
            });
            
            // 添加背景动画
            function updateBackground() {
                var hue = (Date.now() / 50) % 360;
                $('body').css('background', 
                    'linear-gradient(135deg, hsl(' + (hue) + ', 50%, 20%), hsl(' + (hue + 60) + ', 50%, 20%))');
                requestAnimationFrame(updateBackground);
            }
            updateBackground();
        });
    </script>
</body>
</html>

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值