CSS3鼠标悬停图标导航动画特效

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CSS3鼠标悬停图标导航动画特效</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Arial', sans-serif;
        }
        
        body {
            background-color: #f5f7fa;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            color: #333;
        }
        
        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 40px 20px;
            text-align: center;
        }
        
        h1 {
            font-size: 2.5rem;
            margin-bottom: 30px;
            color: #2c3e50;
            position: relative;
        }
        
        h1:after {
            content: '';
            display: block;
            width: 80px;
            height: 4px;
            background: linear-gradient(to right, #3498db, #9b59b6);
            margin: 15px auto;
            border-radius: 2px;
        }
        
        .note {
            background-color: rgba(155, 89, 182, 0.1);
            padding: 15px;
            border-left: 4px solid #9b59b6;
            margin: 20px 0 40px;
            border-radius: 0 4px 4px 0;
        }
        
        .note a {
            color: #9b59b6;
            text-decoration: none;
            font-weight: bold;
        }
        
        .note a:hover {
            text-decoration: underline;
        }
        
        .nav-container {
            display: flex;
            justify-content: center;
            flex-wrap: wrap;
            gap: 20px;
            margin-top: 50px;
        }
        
        .nav-item {
            width: 80px;
            height: 80px;
            background-color: white;
            border-radius: 20px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            position: relative;
            overflow: hidden;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
            transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
        }
        
        .nav-item:hover {
            transform: translateY(-10px);
            box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
        }
        
        /* 图标样式 */
        .nav-icon {
            font-size: 24px;
            color: #2c3e50;
            transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
            position: relative;
            z-index: 2;
        }
        
        .nav-text {
            position: absolute;
            font-size: 12px;
            font-weight: bold;
            color: white;
            bottom: -30px;
            opacity: 0;
            transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
            z-index: 2;
        }
        
        /* 背景效果 */
        .nav-item:before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(45deg, #3498db, #9b59b6);
            transform: scale(0);
            transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
            border-radius: 20px;
            opacity: 0;
        }
        
        .nav-item:hover:before {
            transform: scale(1);
            opacity: 1;
        }
        
        .nav-item:hover .nav-icon {
            color: white;
            transform: translateY(-10px);
        }
        
        .nav-item:hover .nav-text {
            bottom: 15px;
            opacity: 1;
        }
        
        /* 不同导航项的颜色变化 */
        .nav-item:nth-child(1):before {
            background: linear-gradient(45deg, #3498db, #2ecc71);
        }
        
        .nav-item:nth-child(2):before {
            background: linear-gradient(45deg, #e74c3c, #f39c12);
        }
        
        .nav-item:nth-child(3):before {
            background: linear-gradient(45deg, #9b59b6, #34495e);
        }
        
        .nav-item:nth-child(4):before {
            background: linear-gradient(45deg, #1abc9c, #3498db);
        }
        
        .nav-item:nth-child(5):before {
            background: linear-gradient(45deg, #f1c40f, #e67e22);
        }
        
        .nav-item:nth-child(6):before {
            background: linear-gradient(45deg, #e74c3c, #9b59b6);
        }
        
        /* 脉冲动画效果 */
        .nav-item:after {
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            width: 5px;
            height: 5px;
            background: rgba(255, 255, 255, 0.5);
            border-radius: 50%;
            transform: translate(-50%, -50%) scale(1);
            opacity: 0;
            transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
        }
        
        .nav-item:hover:after {
            animation: pulse 1s ease-out;
        }
        
        @keyframes pulse {
            0% {
                transform: translate(-50%, -50%) scale(1);
                opacity: 0.5;
            }
            100% {
                transform: translate(-50%, -50%) scale(20);
                opacity: 0;
            }
        }
        
        /* 响应式设计 */
        @media (max-width: 768px) {
            .nav-container {
                gap: 15px;
            }
            
            .nav-item {
                width: 70px;
                height: 70px;
                border-radius: 15px;
            }
            
            .nav-icon {
                font-size: 20px;
            }
            
            .nav-text {
                font-size: 10px;
            }
        }
        
        @media (max-width: 480px) {
            .nav-container {
                gap: 10px;
            }
            
            .nav-item {
                width: 60px;
                height: 60px;
                border-radius: 12px;
            }
            
            .nav-icon {
                font-size: 18px;
            }
        }
    </style>
    <!-- 引入Font Awesome图标库 -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
</head>
<body>
    <div class="container">
        <h1>CSS3鼠标悬停图标导航动画特效</h1>
        
        
        <div class="nav-container">
            <div class="nav-item">
                <i class="fas fa-home nav-icon"></i>
                <span class="nav-text">首页</span>
            </div>
            
            <div class="nav-item">
                <i class="fas fa-user nav-icon"></i>
                <span class="nav-text">个人中心</span>
            </div>
            
            <div class="nav-item">
                <i class="fas fa-envelope nav-icon"></i>
                <span class="nav-text">消息</span>
            </div>
            
            <div class="nav-item">
                <i class="fas fa-cog nav-icon"></i>
                <span class="nav-text">设置</span>
            </div>
            
            <div class="nav-item">
                <i class="fas fa-heart nav-icon"></i>
                <span class="nav-text">收藏</span>
            </div>
            
            <div class="nav-item">
                <i class="fas fa-bell nav-icon"></i>
                <span class="nav-text">通知</span>
            </div>
        </div>
    </div>
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值