保姆级前端翻牌效果(CSS)

效果

翻牌效果

hover 时候

代码直接上

javascript 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .card{
            margin: 30px auto;
            margin-top: 150px;
            width: 500px;
            height: 500px;
            perspective: 800px;
        }
        .front, .back{
            width: 100%;
            height: 100%;
            border-radius: 20px;
            position: absolute;
            backface-visibility: hidden;
            transition: all 1s cubic-bezier(0.7,0,0.3,1.5);
            background-size: contain;
        }
        .card:hover .front{
            transform: rotateY(180deg);
        }
        .card:hover .back{
            transform: rotateY(0deg);
        }
        .front{
            background: url(./1699939478452.png);
        }
        .back{
            background: url(./1699939494340.png);
            transform: rotateY(180deg);
        }
    </style>
</head>
<body>
    <div class="card">
        <div class="front"></div>
        <div class="back"></div>
    </div>
</body>
</html>
相关推荐
excel1 小时前
ES6 中函数的双重调用方式:fn() 与 fn\...``
前端
可乐爱宅着1 小时前
全栈框架next.js入手指南
前端·next.js
你的人类朋友3 小时前
什么是API签名?
前端·后端·安全
会豪5 小时前
Electron-Vite (一)快速构建桌面应用
前端
中微子5 小时前
React 执行阶段与渲染机制详解(基于 React 18+ 官方文档)
前端
唐某人丶5 小时前
教你如何用 JS 实现 Agent 系统(2)—— 开发 ReAct 版本的“深度搜索”
前端·人工智能·aigc
中微子5 小时前
深入剖析 useState产生的 setState的完整执行流程
前端
遂心_5 小时前
JavaScript 函数参数传递机制:一道经典面试题解析
前端·javascript
小徐_23336 小时前
uni-app vue3 也能使用 Echarts?Wot Starter 是这样做的!
前端·uni-app·echarts
RoyLin6 小时前
TypeScript设计模式:适配器模式
前端·后端·node.js