在需要輪播的頁面是引入swiper.min.js和swiper.min.css
swiper.min.js地址:
鏈接:https://pan.baidu.com/s/15Uh516YHa4CV3X-RyjEIWw
提取碼:4aks
swiper.min.css地址
鏈接:https://pan.baidu.com/s/1S5FEIQMEW0P1jSIqVlzM5A
提取碼:76xb
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Swiper demo</title> <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1"> <!-- Link Swiper's CSS --> <link rel="stylesheet" href="https://www.cnblogs.com/xhj-java/p/swiper.min.css"> <!-- Demo styles --> <style> html, body { position: relative; height: 100%; } body { background: #eee; font-family: Helvetica Neue, Helvetica, Arial, sans-serif; font-size: 14px; color:#000; margin: 0; padding: 0; } .swiper-container { width: 80%; /* height: 100%; */ } .swiper-slide { height: 100px; text-align: center; font-size: 18px; background: #fff; /* Center slide text vertically */ display: -webkit-box; display: -ms-flexbox; display: -webkit-flex; display: flex; -webkit-box-pack: center; -ms-flex-pack: center; -webkit-justify-content: center; justify-content: center; -webkit-box-align: center; -ms-flex-align: center; -webkit-align-items: center; align-items: center; } </style> </head> <body> <!-- Swiper --> <div > <div > <div >Slide 1</div> <div >Slide 2</div> <div >Slide 3</div> <div >Slide 4</div> <div >Slide 5</div> </div> <!-- Add Pagination --> <div ></div> <div ></div> <div ></div> </div> <!-- Swiper JS --> <script src="https://www.cnblogs.com/xhj-java/p/swiper.min.js"></script> <!-- Initialize Swiper 下面這個必須在頁面下面引入 或者自己寫延時加載 --> <script> var swiper = new Swiper('.swiper-container', { slidesPerView: 5,//每一屏顯示幾張圖片 spaceBetween: 30, loop:true,//回圈 pagination: { el: '.swiper-pagination', clickable: true, }, navigation: { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev', }, }); </script> </body> </html>
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/882.html
標籤:HTML5
上一篇:關于a標簽的講解