CSS特效---HTML+CSS实现3D旋转卡片

1、演示

2、一切尽在代码中

html 复制代码
<!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>
      * {
        margin: 0;
        padding: 0;
      }
      body {
        height: 100vh;
        display: flex;
        justify-content: center;
        align-items: center;
        background-color: #5ee7df;
        perspective: 200px;
      }
      .card {
        position: relative;
        width: 300px;
        height: 450px;
        border-radius: 30px;
        cursor: pointer;
        background-color: #fff;
        box-shadow: 1px 1px 20px rgba(0, 0, 0, 0.1);
        transform-style: preserve-3d;
        animation: rotate-reverse 1.2s cubic-bezier(0.66, -0.47, 0.33, 1.5) forwards;
        backface-visibility: hidden;
      }
      .card:hover {
        animation: rotate 1.2s cubic-bezier(0.66, -0.47, 0.33, 1.5) forwards;
      }

      .front,
      .back {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: space-around;
        font-size: 20px;
        background-color: #fff;
        border-radius: 30px;
      }
      .back {
        transform: rotateY(180deg);
        backface-visibility: hidden;
      }
      @keyframes rotate {
        0% {
          transform: rotateY(0deg);
        }
        100% {
          transform: rotateY(180deg);
        }
      }
      @keyframes rotate-reverse {
        0% {
          transform: rotateY(180deg);
        }
        100% {
          transform: rotateY(0deg);
        }
      }
    </style>
  </head>
  <body>
    <div class="card">
      <div class="front">
        <p>今天天气真好!</p>
      </div>
      <div class="back">
        <p>look me~</p>
        <p>look me~</p>
        <p>look me~</p>
        <p>look me~</p>
      </div>
    </div>
  </body>
</html>
相关推荐
用户2149651589875几秒前
从零搭建uniapp环境-记录
前端
努力写代码的熊大2 小时前
stack、queue与priority_queue的用法解析与模拟实现
java·前端·javascript
im_AMBER2 小时前
React 06
前端·javascript·笔记·学习·react.js·前端框架
wyzqhhhh2 小时前
前端常见的设计模式
前端·设计模式
IT_陈寒2 小时前
React 19重磅前瞻:10个性能优化技巧让你少写30%的useEffect代码
前端·人工智能·后端
今天没有盐3 小时前
💕CSS 基础入门指南💕:选择器与文本样式
前端·html·响应式设计
云枫晖3 小时前
Webpack系列-Entry入口
前端·webpack
mustfeng4 小时前
VCS & Verdi 2023安装
java·服务器·前端
Mintopia4 小时前
🌐 数据合规框架下的 WebAIGC 训练数据处理技术规范
前端·javascript·aigc
骥龙4 小时前
2.6、Web漏洞挖掘实战(下):XSS、文件上传与逻辑漏洞深度解析
前端·xss