CSS扑克牌动画效果

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CSS扑克牌动画效果 </title>
    <style>
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            background: linear-gradient(135deg, #2c3e50, #4ca1af);
            font-family: Arial, sans-serif;
            overflow: hidden;
        }

        .card-container {
            position: relative;
            width: 300px;
            height: 450px;
            perspective: 1000px;
        }

        .card {
            position: relative;
            width: 100%;
            height: 100%;
            transform-style: preserve-3d;
            transition: transform 1s;
            cursor: pointer;
        }

        .card:hover {
            transform: rotateY(180deg);
        }

        .card-face {
            position: absolute;
            width: 100%;
            height: 100%;
            backface-visibility: hidden;
            border-radius: 15px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 24px;
            font-weight: bold;
            color: white;
        }

        .card-front {
            background: linear-gradient(45deg, #ff416c, #ff4b2b);
            transform: rotateY(0deg);
        }

        .card-back {
            background: linear-gradient(45deg, #4776e6, #8e54e9);
            transform: rotateY(180deg);
            display: flex;
            flex-direction: column;
            text-align: center;
            padding: 20px;
        }

        .card-back p {
            margin: 10px 0;
            font-size: 16px;
        }

        .card-corner {
            position: absolute;
            font-size: 20px;
            padding: 10px;
        }

        .top-left {
            top: 0;
            left: 0;
        }

        .bottom-right {
            bottom: 0;
            right: 0;
            transform: rotate(180deg);
        }

        .card-suit {
            font-size: 80px;
            margin: 20px 0;
        }

        .credit {
            position: absolute;
            bottom: 20px;
            right: 20px;
            color: white;
            font-size: 12px;
            opacity: 0.7;
        }

        /* 动画效果 */
        @keyframes float {
            0%, 100% {
                transform: translateY(0);
            }
            50% {
                transform: translateY(-20px);
            }
        }

        .card-container {
            animation: float 3s ease-in-out infinite;
        }

        /* 更多卡片 */
        .more-cards {
            position: absolute;
            width: 100%;
            height: 100%;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .more-cards .card {
            position: absolute;
            width: 90%;
            height: 90%;
            opacity: 0.7;
        }

        .more-cards .card:nth-child(1) {
            transform: rotate(-5deg) translateX(-10px);
            z-index: -1;
            background: #3498db;
        }

        .more-cards .card:nth-child(2) {
            transform: rotate(5deg) translateX(10px);
            z-index: -2;
            background: #e74c3c;
        }
    </style>
</head>
<body>
    <div class="card-container">
        <div class="card">
            <div class="card-face card-front">
                <div class="card-corner top-left">A</div>
                <div class="card-suit">♥</div>
                <div class="card-corner bottom-right">A</div>
            </div>
            <div class="card-face card-back">
                <h2>扑克牌</h2>
                <p>CSS动画效果展示</p>
                <p>悬停翻转卡片</p>

            </div>
        </div>
    </div>

    <div class="more-cards">
        <div class="card"></div>
        <div class="card"></div>
    </div>


</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值