CSS实现一张简易的贺卡

效果


当你把鼠标移至贺卡上时,贺卡会缓慢打开。

代码如下


css 复制代码
<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            display: flex;
            justify-content: center;
            align-items: center;
            width: 100vw;
            height: 100vh;
            background: #2e3c50;
        }

        .card {
            width: 300px;height: 200px;
            display: flex;
            justify-content: center;
            align-items: center;
            background: gold;
            color: cornsilk;
            position: relative;
            transform-style: preserve-3d;
            transform: perspective(900px) rotateX(55deg);
            font-size: 2em;
            cursor: pointer;
        }
        .card::before, .card::after {
            width: 50%;height: 100%;
            position: absolute;
            background: #e11a52;
            top: 0;
            align-items: center;
            display: flex;
            box-sizing: border-box;
            transition: 2s;
            
        }
        .card::before {
            content: "新年";
            left: 0;
            justify-content: flex-end;
            border-right: 2px solid black;
            padding-right: 10px;
            transform-origin: left;
        }
        .card::after {
            content: "快乐";
            right: 0;
            border-left: 2px solid black;
            padding-left: 10px;
            transform-origin: right;
        }
        .card:hover::before {
            transform: rotateY(-180deg);    
        }
        .card:hover::after {
            transform: rotateY(180deg);
        }


        /* card background: gold; color: c* */


        /* card::before background: #e11a52; */
    </style>
</head>

<body>
    <div class="card">JAVA</div>
</body>

</html>
相关推荐
半点寒12W1 小时前
微信小程序实现路由拦截的方法
前端
某公司摸鱼前端2 小时前
uniapp socket 封装 (可拿去直接用)
前端·javascript·websocket·uni-app
要加油哦~2 小时前
vue | 插件 | 移动文件的插件 —— move-file-cli 插件 的安装与使用
前端·javascript·vue.js
小林学习编程2 小时前
Springboot + vue + uni-app小程序web端全套家具商场
前端·vue.js·spring boot
柳鲲鹏2 小时前
WINDOWS最快布署WEB服务器:apache2
服务器·前端·windows
weixin-a153003083163 小时前
【playwright篇】教程(十七)[html元素知识]
java·前端·html
ai小鬼头4 小时前
AIStarter最新版怎么卸载AI项目?一键删除操作指南(附路径设置技巧)
前端·后端·github
一只叫煤球的猫4 小时前
普通程序员,从开发到管理岗,为什么我越升职越痛苦?
前端·后端·全栈
vvilkim5 小时前
Electron 自动更新机制详解:实现无缝应用升级
前端·javascript·electron
vvilkim5 小时前
Electron 应用中的内容安全策略 (CSP) 全面指南
前端·javascript·electron