CSS3 新年贺卡

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>新年贺卡</title>
</head>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        body{
            background: #2c3e50;
            width: 100vw;
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        .card{
            width: 300px;
            height: 200px;
            background: tomato;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 2em;
            color: whitesmoke;
            position: relative;
            transform-style: preserve-3d;
            transform: perspective(900px) rotateX(45deg) rotateY(25deg);
        }
        .card::before,.card::after{
            content: '';
            background: #e74c3c;
            width: 50%;
            height: 100%;
            position: absolute;
            transition: 2s;
        }
        .card::before{
            content: '新年';
            left: 0;
            top: 0;
            display: flex;
            justify-content: flex-end;
            align-items: center;
            transform-origin: left;/*参考点*/
            border-right: solid 3px #e67e22;
            box-sizing: border-box;/*被盖住了*/
            padding-right: 10px;
        }
        .card::after{
            content: '快乐';
            right: 0;
            top: 0;
            display: flex;
            justify-content: flex-start;
            align-items: center;
            transform-origin: right;/*参考点*/
            border-left: solid 3px #e67e22;
            box-sizing: border-box;
            padding-left: 10px;
        }
        .card:hover::before{
            transform: rotateY(-180deg);/*旋转*/
        }
        .card:hover::after{
            transform: rotateY(180deg);/*旋转*/
        }
    </style>
<body>
    <div class="card">红包送我</div>
</body>
</html>

 

点赞

发表评论

昵称和uid可以选填一个,填邮箱必填(留言回复后将会发邮件给你)
tips:输入uid可以快速获得你的昵称和头像