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: 'Microsoft YaHei', sans-serif;
            background-color: #f5f5f5;
        }

        .nav-container {
            width: 100%;
            background: linear-gradient(to right, #1e5799, #207cca);
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
        }

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

        .nav-item {
            position: relative;
            padding: 15px 25px;
        }

        .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;
            display: block;
        }

        .nav-link:after {
            content: '';
            position: absolute;
            bottom: -5px;
            left: 0;
            width: 0;
            height: 3px;
            background-color: #ffcc00;
            transition: width 0.3s ease;
        }

        .nav-item:hover .nav-link {
            color: #ffcc00;
        }

        .nav-item:hover .nav-link:after {
            width: 100%;
        }

        .flash-animation {
            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-animation {
            transform: scaleX(1);
        }

        .credit {
            text-align: center;
            margin-top: 30px;
            color: #666;
            font-size: 14px;
        }

        .credit a {
            color: #1e5799;
            text-decoration: none;
        }
    </style>
</head>
<body>
    <div class="nav-container">
        <ul class="nav-menu">
            <li class="nav-item">
                <div class="flash-animation"></div>
                <a href="#" class="nav-link">首页</a>
            </li>
            <li class="nav-item">
                <div class="flash-animation"></div>
                <a href="#" class="nav-link">产品</a>
            </li>
            <li class="nav-item">
                <div class="flash-animation"></div>
                <a href="#" class="nav-link">服务</a>
            </li>
            <li class="nav-item">
                <div class="flash-animation"></div>

            </li>
            <li class="nav-item">
                <div class="flash-animation"></div>
                <a href="#" class="nav-link">关于我们</a>
            </li>
            <li class="nav-item">
                <div class="flash-animation"></div>
                <a href="#" class="nav-link">联系我们</a>
            </li>
        </ul>
    </div>

    <div class="credit">
       
    </div>

    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script>
        $(document).ready(function() {
            // 鼠标悬停动画效果
            $('.nav-item').hover(
                function() {
                    // 鼠标进入
                    $(this).find('.flash-animation').css('transform', 'scaleX(1)');
                    $(this).find('.nav-link').css('color', '#ffcc00');
                },
                function() {
                    // 鼠标离开
                    $(this).find('.flash-animation').css('transform', 'scaleX(0)');
                    $(this).find('.nav-link').css('color', 'white');
                }
            );

            // 点击导航项添加活动状态
            $('.nav-item').click(function() {
                $('.nav-item').removeClass('active');
                $(this).addClass('active');
            });

            // 添加波纹点击效果
            $('.nav-link').click(function(e) {
                e.preventDefault();

                var x = e.pageX - $(this).offset().left;
                var y = e.pageY - $(this).offset().top;

                var ripple = $('<span class="ripple"></span>');
                ripple.css({
                    'left': x,
                    'top': y
                });

                $(this).append(ripple);

                setTimeout(function() {
                    ripple.remove();
                }, 1000);
            });
        });
    </script>
</body>
</html>

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值