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>
相关推荐
周星星日记1 分钟前
11.vue3中组件实现原理(中)
前端·vue.js·面试
WEI_Gaot4 分钟前
TS 为什么使用ts 和 创建ts的环境
前端·typescript
WEI_Gaot5 分钟前
TS 的类型注解大全
前端·typescript
i_am_a_div_日积月累_28 分钟前
前端路由缓存实现
前端·javascript·vue.js
咪库咪库咪1 小时前
异步js和http请求
前端
厨猿加加1 小时前
FlatList 在 React Native 的最佳实践
前端·react native
用户2880007486741 小时前
前端连接VNC(无需后端)的完整教程
前端
郝某人一生平安1 小时前
前端 Word 模板参入特定数据 并且下载
前端·vue.js
jaffees1 小时前
自定义多级联动选择器(uni-app)
前端
_一条咸鱼_1 小时前
深入剖析 Vue 过滤器模块(十三)
前端·javascript·面试