立方体轮播图swiper实现

立方体四面实现旋转轮播图

需要的同学可以贴上图像,很炫酷,主要是swiper,当然使用effect也可以实现

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Rotating Cube with Swiper</title>
  <link rel="stylesheet" href="https://unpkg.com/swiper/swiper-bundle.min.css">
  <style>
    /* 定义容器样式 */
    body, html {
      height: 100%;
      margin: 0;
      display: flex;
      justify-content: center;
      align-items: center;
    }

    .swiper-container {
      width: 400px;
      height: 400px;
      perspective: 1000px;
    }

    /* Define styles for the cube */
    .cube {
      width: 100%;
      height: 100%;
      position: relative;
      transform-style: preserve-3d;
      animation: rotate 10s infinite linear;
    }

    @keyframes rotate {
      from {
        transform: rotateY(0deg);
      }
      to {
        transform: rotateY(360deg);
      }
    }

    /*定义面的样式 */
    .face {
      position: absolute;
      width: 100%;
      height: 100%;
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 24px;
      font-weight: bold;
      backface-visibility: hidden;
    }

    /* 定义每一个面*/
    .face1 { background-color: red; transform: rotateY(0deg) translateZ(200px); }
    .face2 { background-color: green; transform: rotateY(90deg) translateZ(200px); }
    .face3 { background-color: blue; transform: rotateY(180deg) translateZ(200px); }
    .face4 { background-color: yellow; transform: rotateY(-90deg) translateZ(200px); }
  </style>
</head>
<body>
  <div class="swiper-container">
    <div class="swiper-wrapper">
      <div class="swiper-slide">
        <div class="cube">
          <div class="face face1">1</div>
          <div class="face face2">2</div>
          <div class="face face3">3</div>
          <div class="face face4">4</div>
        </div>
      </div>
    </div>
  </div>

  <script src="https://unpkg.com/swiper/swiper-bundle.min.js"></script>
  <script>
    var swiper = new Swiper('.swiper-container', {
      slidesPerView: 1,
      spaceBetween: 30,
      loop: true,
      speed: 3000,
      autoplay: {
        delay: 0,
        disableOnInteraction: false,
      },
    });
  </script>
</body>
</html>

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值