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>
相关推荐
我是大头鸟38 分钟前
SpringMVC 内容协商处理
前端
Humbunklung38 分钟前
Visual Studio 2022 中添加“高级保存选项”及解决编码问题
前端·c++·webview·visual studio
墨水白云1 小时前
nestjs[一文学懂nestjs中对npm功能包的封装,ioredis封装示例]
前端·npm·node.js
满怀10151 小时前
【Vue 3全栈实战】从响应式原理到企业级架构设计
前端·javascript·vue.js·vue
luckywuxn2 小时前
使用gitbook 工具编写接口文档或博客
前端
梅子酱~2 小时前
Vue 学习随笔系列二十三 -- el-date-picker 组件
前端·vue.js·学习
伟笑2 小时前
elementUI 循环出来的表单,怎么做表单校验?
前端·javascript·elementui
辣辣y2 小时前
React中useMemo和useCallback的作用:
前端·react
Alice-YUE2 小时前
【HTML5学习笔记1】html标签(上)
前端·笔记·学习·html·html5
Alice-YUE2 小时前
【HTML5学习笔记2】html标签(下)
前端·笔记·html·html5