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>
相关推荐
代码不停8 小时前
前端基础知识
javascript·css·html
soul g8 小时前
npm 包发布流程
前端·npm·node.js
踢球的打工仔8 小时前
jquery的基本使用(5)
前端·javascript·jquery
开发者小天8 小时前
react中的useDebounceEffect用法
前端·react.js·前端框架
想自律的露西西★8 小时前
js.39. 组合总和
前端·javascript·数据结构·算法
ttod_qzstudio8 小时前
事件冒泡踩坑记:一个TDesign Checkbox引发的思考
前端·javascript·vue.js·tdesign
IT_陈寒8 小时前
Vue3性能优化实战:这7个技巧让我的应用加载速度提升40%
前端·人工智能·后端
Reuuse8 小时前
登录突然失效:Axios 拦截器判空、localStorage 脏数据与环境变量踩坑
开发语言·前端
早川不爱吃香菜8 小时前
MCP 教程:将 Figma 设计稿转化为前端代码
前端·figma
修炼前端秘籍的小帅8 小时前
PinMe——极简、免费和无需服务器的开源前端部署工具
前端