CSS 3.0实现定价卡展开特效

2020-11-26 10:33:45 浏览数 (1)

给大家分享一个用CSS 3.0实现的定价卡展开特效,效果如下:

以下是代码实现,欢迎大家复制粘贴和收藏。

代码语言:javascript复制
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CSS 3.0实现定价卡展开特效</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            font-family: '微软雅黑', sans-serif;
        }

        body {
            display: flex;
            align-items: center;
            justify-content: center;
            min-height: 100vh;
        }

        .container {
            position: relative;
            display: flex;
            width: 1100px;
            justify-content: space-between;
            align-items: center;
        }

        .container .card {
            position: relative;
            width: 300px;
            cursor: pointer;
        }

        .container .card .name {
            position: relative;
            padding: 10px 0;
            border: 2px solid #000;
            text-align: center;
            background: #fff;
            z-index: 1;
        }

        .container .card .name h3 {
            font-weight: 500;
            font-size: 1.5em;
        }

        .container .card .details {
            position: relative;
            text-align: center;
            height: 0px;
            transition: 0.5s;
            border: 2px solid #000;
            margin-top: -2px;
            overflow: hidden;
            top: -2px;
        }

        .container .card:hover .details {
            height: 316px;
        }

        .container .card .details .content {
            position: relative;
            padding: 40px 20px;
        }

        .container .card .details .content h2 {
            font-size: 3em;
            font-weight: 500;
        }

        .container .card .details .content h2 span {
            font-size: 0.4em;
        }

        .container .card .details .content a {
            position: relative;
            display: inline-block;
            padding: 10px 20px;
            margin-top: 15px;
            background: rgba(0, 0, 0, 0.9);
            color: #fff;
            text-decoration: none;
        }

        .container .card:nth-child(1) .name {
            background: #d2fff2;
        }

        .container .card:nth-child(1) .details {
            background: #f1fffb;
        }

        .container .card:nth-child(2) .name {
            background: #fcffd2;
        }

        .container .card:nth-child(2) .details {
            background: #ffffe2;
        }

        .container .card:nth-child(3) .name {
            background: #fed2ff;
        }

        .container .card:nth-child(3) .details {
            background: #ffeeff;
        }
    </style>
</head>

<body>
    <div class="container">
        <div class="card">
            <div class="name">
                <h3>免费</h3>
            </div>
            <div class="details">
                <div class="content">
                    <h2>¥0 <span>/月</span></h2>
                    <p>放弃该放弃的是无奈,放弃不该放弃的是无能;不放弃该放弃的是无知,不放弃不该放弃的是执着。</p>
                    <a href="#">试一试</a>
                </div>
            </div>
        </div>
        <div class="card">
            <div class="name">
                <h3>基础</h3>
            </div>
            <div class="details">
                <div class="content">
                    <h2>¥100 <span>/月</span></h2>
                    <p>放弃该放弃的是无奈,放弃不该放弃的是无能;不放弃该放弃的是无知,不放弃不该放弃的是执着。</p>
                    <a href="#">立即购买</a>
                </div>
            </div>
        </div>
        <div class="card">
            <div class="name">
                <h3>升级</h3>
            </div>
            <div class="details">
                <div class="content">
                    <h2>¥1000 <span>/月</span></h2>
                    <p>放弃该放弃的是无奈,放弃不该放弃的是无能;不放弃该放弃的是无知,不放弃不该放弃的是执着。</p>
                    <a href="#">立即购买</a>
                </div>
            </div>
        </div>
    </div>
</body>

</html>

0 人点赞