今天的輪播圖,和往常的有一點點不同哦!可以說是有一點點的3D效果!因為他在運動的時候,是以正方體的樣子左右滾動的; 先引插件: <link rel="stylesheet" href="swiper.css"> <script src="swiper.js"></script> 然後還是那句話:翠花 ...
今天的輪播圖,和往常的有一點點不同哦!可以說是有一點點的3D效果!因為他在運動的時候,是以正方體的樣子左右滾動的;
先引插件:
<link rel="stylesheet" href="swiper.css">
<script src="swiper.js"></script>
然後還是那句話:翠花,上代碼:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Swiper demo</title> <meta name="viewport" content="width=device-width,initial-scale=1"/> <link rel="stylesheet" href="swiper.css"> <style> /*樣式*/ html, body { position: relative; height: 100%; } body { background: #fff; font-family: Helvetica Neue, Helvetica, Arial, sans-serif; font-size: 14px; color:#000; margin: 0; padding: 0; } img{ width: 100%; height: 100%; } .swiper-container { width: 500px; height: 500px; position: absolute; left: 45%; top: 35%; margin-left: -150px; margin-top: -150px; } .swiper-slide { background-position: center; background-size: cover; } </style> </head> <body> <!-- Swiper輪播圖 --> <div class="swiper-container"> <div class="swiper-wrapper"> <div class="swiper-slide"><img src="../img/2d.jpg"/></div> <div class="swiper-slide"><img src="../img/2d.jpg"/></div> <div class="swiper-slide"><img src="../img/2d.jpg"/></div> <div class="swiper-slide"><img src="../img/2d.jpg"/></div> <div class="swiper-slide"><img src="../img/2d.jpg"/></div> </div> <div class="swiper-pagination"></div> </div> <script src="swiper.js"></script> <script> var swiper = new Swiper('.swiper-container', { pagination: '.swiper-pagination', //迴圈 往返的動 loop:true, //小白點不能點擊 autoplayDisableOnInteraction:false, effect: 'cube', grabCursor: true, cube: { shadow: true, slideShadows: true, shadowOffset: 20, shadowScale: 0.94 } }); </script> </body> </html>
有沒有很簡單啊!!!