3D角色展示

先看效果:

再看代码:

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>3D卡片悬停</title>
  <style>
    @font-face {
      font-family: "Exoct";
      src: url("https://assets.codepen.io/1480814/films.EXH_____.ttf")
    }
    figure {
      width: 100%;
      aspect-ratio: 1;
      margin: 0 0 60px;
      padding: 5px 20px 0;
      box-sizing: border-box;
      display: grid;
      grid-template-rows: 100%;
      cursor: pointer;
      position: relative;
      filter: drop-shadow(0 0 20px rgb(0 0 0/50%));
    }
    figure:before {
      content: "";
      position: absolute;
      z-index: -1;
      inset: 0;
      background: top/cover;
      transform-origin: bottom;
      filter: brightness(.9);
      transition: .5s;
    }
    figure:before {
      background-image: url(https://assets.codepen.io/1480814/necro-back.jpg)
    }
    figure + figure:before {
      background-image: url(https://assets.codepen.io/1480814/druid-bac.jpg)
    }
    img {
      grid-area: 1/1;
      width: 100%;
      height: 100%;
      object-fit: cover;
      object-position: top;
      filter: contrast(.8) brightness(.7);
      place-self: end center;
      transition: .5s;
    }
    figcaption {
      grid-area: 1/1;
      width: calc(100% + 40px);
      font-family: Exoct;
      color: #fff;
      font-size: min(32px,5vmin);
      text-align: center;
      place-self: end center;
      transform: perspective(500px) translateY(100%) rotateX(-90deg);
      backface-visibility: hidden;
      transform-origin: top;
      background: #000;
      transition: .5s;
    }
    figure:hover img {
      width: 130%;
      height: 255%;
      filter: contrast(1);
    }
    figure:hover::before {
      filter: brightness(.3);
      transform: perspective(500px) rotateX(60deg);
    }
    figure:hover figcaption{
      transform: perspective(500px)translateY(100%) rotateX(-30deg);
    }

    body {
      margin: 0;
      min-height: 100vh;
      display: grid;
      grid-auto-flow: column;
      grid-auto-columns: min(230px,35vmin);
      place-content: end center;
      gap: 50px;
      background:
              linear-gradient(#0000,rgb(50 50 50 / 88%)),
              url(https://assets.codepen.io/1480814/diablo-reaper-of-souls-mw-1360x768.jpg) top/cover;
    }

  </style>
</head>
<body>
<figure>
  <img src="https://assets.codepen.io/1480814/necro.png" alt="Necromancer">
  <figcaption>The Necro</figcaption>
</figure>
<figure>
  <img src="https://assets.codepen.io/1480814/druide.png" alt="Druid">
  <figcaption>The Druid</figcaption>
</figure>

</body>
</html>
相关推荐
苏打水com2 小时前
第十九篇:Day55-57 前端工程化进阶——从“手动低效”到“工程化高效”(对标职场“规模化”需求)
前端·css·vue·html
kirinlau4 小时前
vue3+vite+scss项目使用tailwindcss
前端·css·scss
中科米堆5 小时前
中科米堆CASAIM自动化三维检测-0.02mm计量级精度产品尺寸快速检测
人工智能·3d·3d全尺寸检测
composurext6 小时前
录音切片上传
前端·javascript·css
狮子座的男孩6 小时前
html+css基础:07、css2的复合选择器_伪类选择器(概念、动态伪类、结构伪类(核心)、否定伪类、UI伪类、目标伪类、语言伪类)及伪元素选择器
前端·css·经验分享·html·伪类选择器·伪元素选择器·结构伪类
小白阿龙6 小时前
样式不生效/被覆盖(CSS优先级陷阱)
前端·css
elangyipi1237 小时前
cursor: not-allowed 与 pointer-events: none 深度解析
css
中科米堆7 小时前
自动化大尺寸批量3D检测,自动化三维扫描系统实现钢板支架在线检测-中科米堆CASAIM
运维·3d·自动化·3d全尺寸检测
七月十二7 小时前
类似渐变色弯曲border
css
ttod_qzstudio8 小时前
Vue 3 的魔法:用 v-bind() 让 CSS 爱上 TypeScript 常量
css·vue.js·typescript