这是一款基于swiper.js的立方体轮播图效果。该轮播图使用swiper.js来制作,可以通过鼠标拖拽来旋转立方体,查看每一张图片。
使用方法
HTML代码
<div class="cube-parent-container"> <div class="swiper cubeSwiper"> <div class="swiper-wrapper"> <div class="swiper-slide"> <img src="https://swiperjs.com/demos/images/nature-1.jpg" /> </div> <div class="swiper-slide"> <img src="https://swiperjs.com/demos/images/nature-2.jpg" /> </div> <div class="swiper-slide"> <img src="https://swiperjs.com/demos/images/nature-3.jpg" /> </div> <div class="swiper-slide"> <img src="https://swiperjs.com/demos/images/nature-4.jpg" /> </div> </div> <div class="swiper-pagination"></div> </div> </div>
CSS代码
.cube-parent-container { position: relative; width: 100%; height: 600px; font-family: Helvetica Neue, Helvetica, Arial, sans-serif; font-size: 14px; color: #000; margin: 0; padding: 0; } .cubeSwiper { width: 400px; height: 400px; margin-top: 100px; } .cubeSwiper { background-position: center; background-size: cover; } .cubeSwiper .swiper-slide img { display: block; width: 100%; } .cubeSwiper .swiper-pagination-bullet-active { background: hotpink; }