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>
相关推荐
533_16 小时前
[css] flex布局中的英文字母不换行问题
前端·css
533_1 天前
[css] border 渐变
前端·css
昔人'1 天前
css`text-underline-offset` 为文本下划线设置偏移量
前端·css
ybb_ymm1 天前
前端开发之ps基本使用
前端·css
软件技术NINI1 天前
MATLAB疑难诊疗:从调试到优化的全攻略
javascript·css·python·html
~无忧花开~1 天前
CSS学习笔记(五):CSS媒体查询入门指南
开发语言·前端·css·学习·媒体
嬉皮客1 天前
TailwindCSS 初探
前端·css
小张成长计划..1 天前
前端6:CSS3 2D转换,CSS3动画,CSS3 3D转换
前端·3d·css3
GIS数据转换器1 天前
带高度多边形,生成3D建筑模型,支持多种颜色或纹理的OBJ、GLTF、3DTiles格式
数据库·人工智能·机器学习·3d·重构·无人机
昔人'2 天前
css使用 :where() 来简化大型 CSS 选择器列表
前端·css