头像悬停展示个人信息

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>头像悬停展示个人信息</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Arial', sans-serif;
        }
        
        body {
            background: #f5f5f5;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            padding: 20px;
        }
        
        .container {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            gap: 30px;
            max-width: 1200px;
        }
        
        .profile-card {
            width: 280px;
            height: 350px;
            position: relative;
            perspective: 1000px;
            cursor: pointer;
        }
        
        .profile-inner {
            position: relative;
            width: 100%;
            height: 100%;
            transition: transform 0.8s;
            transform-style: preserve-3d;
        }
        
        .profile-card:hover .profile-inner {
            transform: rotateY(180deg);
        }
        
        .profile-front, .profile-back {
            position: absolute;
            width: 100%;
            height: 100%;
            backface-visibility: hidden;
            border-radius: 15px;
            overflow: hidden;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
        }
        
        .profile-front {
            background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            color: white;
        }
        
        .avatar {
            width: 150px;
            height: 150px;
            border-radius: 50%;
            border: 5px solid rgba(255, 255, 255, 0.3);
            object-fit: cover;
            margin-bottom: 20px;
            transition: all 0.3s;
        }
        
        .profile-card:hover .avatar {
            transform: scale(1.05);
            box-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
        }
        
        .name {
            font-size: 24px;
            font-weight: bold;
            margin-bottom: 5px;
        }
        
        .title {
            font-size: 16px;
            opacity: 0.8;
        }
        
        .profile-back {
            background: white;
            transform: rotateY(180deg);
            padding: 30px;
            display: flex;
            flex-direction: column;
        }
        
        .info-title {
            font-size: 20px;
            font-weight: bold;
            color: #333;
            margin-bottom: 20px;
            text-align: center;
            position: relative;
        }
        
        .info-title::after {
            content: '';
            position: absolute;
            bottom: -10px;
            left: 50%;
            transform: translateX(-50%);
            width: 50px;
            height: 3px;
            background: linear-gradient(to right, #6a11cb, #2575fc);
        }
        
        .info-item {
            display: flex;
            align-items: center;
            margin-bottom: 15px;
        }
        
        .info-icon {
            width: 30px;
            height: 30px;
            background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 15px;
            color: white;
        }
        
        .info-text {
            color: #555;
            font-size: 14px;
        }
        
        .social-links {
            display: flex;
            justify-content: center;
            margin-top: auto;
            gap: 15px;
        }
        
        .social-link {
            width: 35px;
            height: 35px;
            border-radius: 50%;
            background: #f0f0f0;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #555;
            transition: all 0.3s;
            text-decoration: none;
        }
        
        .social-link:hover {
            background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
            color: white;
            transform: translateY(-3px);
        }
        
        .footer {
            position: fixed;
            bottom: 20px;
            width: 100%;
            text-align: center;
            color: #555;
        }
        
        .footer a {
            color: #2575fc;
            text-decoration: none;
            transition: color 0.3s;
        }
        
        .footer a:hover {
            color: #6a11cb;
            text-decoration: underline;
        }
    </style>
</head>
<body>
    <div class="container">
        <!-- 第一个个人资料卡片 -->
        <div class="profile-card">
            <div class="profile-inner">
                <div class="profile-front">
                    <img src="https://randomuser.me/api/portraits/men/32.jpg" alt="头像" class="avatar">
                    <h2 class="name">张伟</h2>
                    <p class="title">前端开发工程师</p>
                </div>
                <div class="profile-back">
                    <h3 class="info-title">个人信息</h3>
                    <div class="info-item">
                        <div class="info-icon">
                            <i>📧</i>
                        </div>
                        <p class="info-text">zhangwei@example.com</p>
                    </div>
                    <div class="info-item">
                        <div class="info-icon">
                            <i>📱</i>
                        </div>
                        <p class="info-text">138-0013-8000</p>
                    </div>
                    <div class="info-item">
                        <div class="info-icon">
                            <i>🏢</i>
                        </div>
                        <p class="info-text">北京市海淀区科技园</p>
                    </div>
                    <div class="social-links">
                        <a href="#" class="social-link">f</a>
                        <a href="#" class="social-link">in</a>
                        <a href="#" class="social-link">t</a>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- 第二个个人资料卡片 -->
        <div class="profile-card">
            <div class="profile-inner">
                <div class="profile-front">
                    <img src="https://randomuser.me/api/portraits/women/44.jpg" alt="头像" class="avatar">
                    <h2 class="name">李娜</h2>
                    <p class="title">UI设计师</p>
                </div>
                <div class="profile-back">
                    <h3 class="info-title">个人信息</h3>
                    <div class="info-item">
                        <div class="info-icon">
                            <i>📧</i>
                        </div>
                        <p class="info-text">lina@example.com</p>
                    </div>
                    <div class="info-item">
                        <div class="info-icon">
                            <i>📱</i>
                        </div>
                        <p class="info-text">139-0013-9000</p>
                    </div>
                    <div class="info-item">
                        <div class="info-icon">
                            <i>🏢</i>
                        </div>
                        <p class="info-text">上海市浦东新区创意园</p>
                    </div>
                    <div class="social-links">
                        <a href="#" class="social-link">f</a>
                        <a href="#" class="social-link">in</a>
                        <a href="#" class="social-link">t</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <div class="footer">
        <p>jQuery头像悬停效果 © 2023</p>
    </div>

    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script>
        $(document).ready(function() {
            // 为卡片添加悬停效果
            $('.profile-card').hover(
                function() {
                    // 鼠标进入
                    $(this).find('.profile-inner').css('transform', 'rotateY(180deg)');
                    $(this).find('.avatar').css({
                        'transform': 'scale(1.05)',
                        'box-shadow': '0 0 20px rgba(255, 255, 255, 0.5)'
                    });
                },
                function() {
                    // 鼠标离开
                    $(this).find('.profile-inner').css('transform', '');
                    $(this).find('.avatar').css({
                        'transform': '',
                        'box-shadow': ''
                    });
                }
            );
            
            // 点击卡片也可以翻转
            $('.profile-card').click(function() {
                $(this).find('.profile-inner').toggleClass('flipped');
            });
            
            // 为社交链接添加动画
            $('.social-link').hover(
                function() {
                    $(this).css({
                        'background': 'linear-gradient(135deg, #6a11cb 0%, #2575fc 100%)',
                        'color': 'white',
                        'transform': 'translateY(-3px)'
                    });
                },
                function() {
                    $(this).css({
                        'background': '#f0f0f0',
                        'color': '#555',
                        'transform': ''
                    });
                }
            );
        });
    </script>
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值