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>
相关推荐
酉鬼女又兒3 小时前
零基础快速入门前端ES6 核心特性详解与蓝桥杯 Web 考点实践(可用于备赛蓝桥杯Web应用开发)
开发语言·前端·职场和发展·蓝桥杯·es6·css3·html5
apcipot_rain6 小时前
CSS知识概述
前端·css
Brookty9 小时前
HTTP应用数据组织、HTML/CSS/JS数据描述及应用层数据处理介绍
css·网络·http·html
北城笑笑9 小时前
Frontend 与 FPGA 深度融合实战解析:从技术协同到多场景落地( 前端和现场可编程门阵列 )
前端·websocket·3d·vue·fpga
奔跑的呱呱牛21 小时前
CSS Grid 布局参数详解(超细化版)+ 中文注释 Demo
前端·css·grid
Yao.Li1 天前
PVN3D 原生 / ONNX 混合 / TRT 混合推理速度测试
人工智能·3d·具身智能
我是伪码农1 天前
HTML和CSS复习
前端·css·html
阿珊和她的猫1 天前
以用户为中心的前端性能指标解析
前端·javascript·css
_耀北1 天前
用 Canvas + CSS 打造“会呼吸”的天气卡片(附源码可复制)
前端·css
牧码岛1 天前
Web前端之样式中的light-dark函数,从媒体查询到颜色函数,从颜色到图片,light-dark打开CSS新时代、主题切换的暗黑模式到image的正解
前端·css·web·web前端