3D堆叠卡片

复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>3D堆叠卡片</title>
    <style>
      * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
      }
      body {
        display: flex;
        justify-content: center;
        align-items: center;
        min-height: 100vh;
        background: #313131;
        perspective: 2500px;
      }
      .container {
        position: relative;
        top: 150px;
        left: 150px;
        width: 300px;
        height: 400px;
        transform-style: preserve-3d;
        transform: rotateY(20deg);
      }
      .card {
        position: absolute;
        top: 0;
        width: 300px;
        height: 300px;
        background: #4a4a4a;
        border-radius: 10px;
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
        transition: .5s;
        font-size: 2em;
        -webkit-text-stroke: 1px #fff5;
        color: transparent;
        font-weight: 700;
        padding: 10px;
        border: 1px solid rgba(0, 0, 0, 1);
        transition: .5s;
      }
      .container .card:hover {
        opacity: 1;
        transition: 0.01s;
        top: -15%;
        color: #333;
        box-shadow: 0 0 50px #64ff74, inset 0 0 120px #64ff74;
        background: #64ff74;
      }
    </style>
</head>
<body>
  <div class="container"></div>
  <script>
    const container = document.querySelector('.container');
    const cardCount = 12;
    for(let i = 0; i < cardCount; i++) {
      const card = document.createElement('div');
      card.classList.add('card');
      card.textContent = `${i + 1}`;
      let zPos = i * -120;
      let yPos = i * -20;
      card.style.transform = `translateZ(${zPos}px) translateY(${yPos}px)`;
      card.style.filter = `hue-rotate(${i * 30}deg)`;
      container.appendChild(card);
    }
  </script>
</body>
</html>
相关推荐
爱看书的小沐1 天前
【小沐杂货铺】基于Three.js绘制三维艺术画廊3DArtGallery (Three.js,WebGL)
javascript·3d·webgl·three.js·babylon.js·三维画廊
格林威1 天前
3D相机视觉检测:环境光太强,结构光点云全是噪点怎么办?
开发语言·人工智能·数码相机·计算机视觉·3d·视觉检测·工业相机
yqcoder1 天前
端经典面试题:为什么 0.1 + 0.2 !== 0.3?
前端·css
ZC跨境爬虫1 天前
跟着 MDN 学 HTML day_12:(HTML网页图片嵌入)
前端·javascript·css·ui·html
用户059540174461 天前
大模型记忆存储踩坑实录:LangChain 的 ConversationBufferMemory 让我排查了 6 小时
前端·css
threelab1 天前
Three.js 3D 饼图效果 | 三维可视化 / AI 提示词
javascript·人工智能·3d
剑神一笑1 天前
CSS Animation Timeline 可视化动画编辑器:从关键帧到流畅动画
前端·css·编辑器
2401_878454531 天前
HTML和CSS的复习2
前端·css·html
We་ct1 天前
吃透现代CSS全技术体系
前端·css·css3·sass·postcss·预处理器
ZC跨境爬虫1 天前
跟着 MDN 学 HTML day_11:(语义化容器全站重构+独立CSS拆分+字体合规引入)
前端·css·ui·重构·html·edge浏览器