3D立方体图册


  
    
    
    3D立方体图册
    
      * {
        padding: 0;
        margin: 0;
        box-sizing: border-box;
      }
      body {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 100vh;
        background: #f5f5f5;
      }
      .box {
        position: relative;
        width: 240px;
        height: 300px;
        transform-style: preserve-3d;
        transform: perspective(1000px) rotateY(180deg);
        transition: 1.5s;
      }
      .box::before {
        content: "";
        position: absolute;
        width: 240px;
        height: 240px;
        background: #2225;
        transform: translateY(240px) rotateX(90deg) scale(1.1);
        filter: blur(40px);
      }
      .card {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 300px;
        background: linear-gradient(90deg, #ddd, #eee);
        transform-origin: center;
        transform: rotateY(calc(var(--i) * 90deg)) translateZ(120px);
      }
      .img-box {
        width: 100%;
        height: 240px;
        text-align: center;
      }
      img {
        width: 100%;
        height: 100%;
        object-fit: cover;
      }
      .img-box h2 {
        color: red;
      }
      .img-box span {
        color: purple;
      }
    
  
  
    
      
        
          
            D立方体图册"
            

公孙离

射手 D立方体图册"

宫本武藏

战士 D立方体图册"

诸葛亮

法师 D立方体图册"

赵云

刺客 const box = document.querySelector(".box"); let isMoving = false; function handleMouseMove(event) { if (!isMoving) { isMoving = true; requestAnimationFrame(() => { const boxWidth = box.offsetWidth; const boxHeight = box.offsetHeight; const mouseX = event.clientX - box.getBoundingClientRect().left; const mouseY = event.clientY - box.getBoundingClientRect().top; const rotateY = (mouseX / boxWidth - 0.5) * 60; // 通过鼠标位置计算 Y 轴旋转角度 const rotateX = (0.5 - mouseY / boxHeight) * 60; // 通过鼠标位置计算 X 轴旋转角度 box.style.transform = `perspective(1000px) rotateX(${rotateX}deg) rotateY(${rotateY}deg)`; isMoving = false; }); } } box.addEventListener("mousemove", handleMouseMove); 在这里插入代码片

在这里插入图片描述

本文来自网络,不代表协通编程立场,如若转载,请注明出处:https://net2asp.com/2e1fec3739.html