jQuery Flash动画导航条

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>jQuery Flash动画导航条</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Arial', sans-serif;
            background-color: #f5f5f5;
        }

        .nav-container {
            width: 100%;
            background: linear-gradient(135deg, #6e8efb, #a777e3);
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        }

        .nav-menu {
            display: flex;
            justify-content: center;
            list-style: none;
            max-width: 1200px;
            margin: 0 auto;
            padding: 0;
        }

        .nav-item {
            position: relative;
            padding: 20px 30px;
        }

        .nav-link {
            color: white;
            text-decoration: none;
            font-size: 16px;
            font-weight: bold;
            text-transform: uppercase;
            letter-spacing: 1px;
            position: relative;
            transition: all 0.3s ease;
            padding: 10px 15px;
        }

        .nav-link:hover {
            color: #ffeb3b;
        }

        .flash-effect {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(255, 255, 255, 0.3);
            transform: scaleX(0);
            transform-origin: left;
            transition: transform 0.3s ease;
            z-index: -1;
        }

        .nav-item:hover .flash-effect {
            transform: scaleX(1);
        }

        .logo {
            margin-right: auto;
            padding-left: 20px;
        }

        .logo a {
            font-size: 24px;
            font-weight: 700;
            color: white;
            text-decoration: none;
        }

        .footer {
            text-align: center;
            margin-top: 50px;
            padding: 20px;
            color: #666;
        }

        .footer a {
            color: #6e8efb;
            text-decoration: none;
        }
    </style>
</head>
<body>
    <div class="nav-container">
        <ul class="nav-menu">
            <li class="logo"><a href="#">LOGO</a></li>
            <li class="nav-item">
                <a href="#" class="nav-link">首页
                    <div class="flash-effect"></div>
                </a>
            </li>
            <li class="nav-item">
                <a href="#" class="nav-link">产品
                    <div class="flash-effect"></div>
                </a>
            </li>
            <li class="nav-item">
                <a href="#" class="nav-link">服务
                    <div class="flash-effect"></div>
                </a>
            </li>
            <li class="nav-item">
                <a href="#" class="nav-link">关于我们
                    <div class="flash-effect"></div>
                </a>
            </li>
            <li class="nav-item">
                <a href="#" class="nav-link">联系我们
                    <div class="flash-effect"></div>
                </a>
            </li>
        </ul>
    </div>

    <div class="content" style="max-width: 1200px; margin: 50px auto; padding: 20px;">
        <h1>欢迎使用jQuery Flash动画导航条</h1>
        <p>这是一个带有Flash动画效果的导航条,当鼠标悬停在菜单项上时,会产生从左到右的闪光效果。</p>
    </div>

    <div class="footer">

    </div>

    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script>
        $(document).ready(function() {
            // 增强Flash动画效果
            $('.nav-item').hover(
                function() {
                    // 鼠标进入
                    $(this).find('.flash-effect').css({
                        'transform': 'scaleX(1)',
                        'opacity': '0.3'
                    });

                    // 添加额外的动画效果
                    $(this).find('.nav-link').css({
                        'transform': 'translateY(-3px)',
                        'text-shadow': '0 0 5px rgba(255, 235, 59, 0.7)'
                    });
                },
                function() {
                    // 鼠标离开
                    $(this).find('.flash-effect').css({
                        'transform': 'scaleX(0)',
                        'opacity': '0'
                    });

                    $(this).find('.nav-link').css({
                        'transform': 'translateY(0)',
                        'text-shadow': 'none'
                    });
                }
            );

            // 点击菜单项时的效果
            $('.nav-link').click(function(e) {
                e.preventDefault();

                // 添加点击闪光效果
                $(this).find('.flash-effect').css({
                    'background-color': 'rgba(255, 255, 255, 0.7)',
                    'transform': 'scaleX(1)'
                }).animate({
                    'opacity': 0
                }, 500, function() {
                    $(this).css({
                        'background-color': 'rgba(255, 255, 255, 0.3)',
                        'transform': 'scaleX(0)'
                    });
                });

                // 这里可以添加页面跳转或内容切换逻辑
                console.log('导航到: ' + $(this).text());
            });
        });
    </script>
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值