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>
相关推荐
龙猫里的小梅啊9 小时前
CSS(四)CSS文本属性
前端·css
爱上好庆祝14 小时前
学习js的第2天
前端·css·学习·html·css3
天外飞雨道沧桑14 小时前
详解CSS中的Containing Block:概念、规则与实战解析
前端·css
三维频道17 小时前
深度解析:3D-DIC技术如何精准表征复合材料的变形与损伤演化?
人工智能·计算机视觉·3d·全场应变测量·dic技术·新拓三维·复合材料力学表征
Yeats_Liao17 小时前
后台 Sidebar 伸缩交互(PC + 移动端)实现
前端·javascript·css·html5
里欧跑得慢18 小时前
微交互设计模式:提升用户体验的细节之美
前端·css·flutter·web
爱上好庆祝20 小时前
学习js第一天(出发新世界)
开发语言·前端·javascript·css·学习·html·ecmascript
DisonTangor20 小时前
【阿里拥抱开源】LingBot-Map:用于流式3D重建的几何上下文转换器
机器学习·3d·机器人·开源
ZC跨境爬虫20 小时前
UI前端美化技能提升日志day6:(使用苹果字体+计算样式对比差异)
前端·javascript·css·ui·状态模式
wei_shuo20 小时前
零门槛开发 3D 数字人:魔珐星云开放平台接入实战
3d·数字人·魔珐星云