一起來了解下Swiper插件的使用和介紹
Swiper介紹
swiper是一款開源的解決前端開發(fā)中觸摸滑動案例的插件
swiper的使用
使用swiper首先要下載swiper
下載完成后在官網(wǎng)在線演示中找到你所需要的
這里我選擇了基礎(chǔ)演示中的010
首先在你下載的壓縮包中找到010的demo文件
打開后點擊鼠標(biāo)右鍵打開網(wǎng)頁源代碼
打開編輯器在自己項目中引入swiper.min.css
swiper-bundle.min.js
兩個文件
復(fù)制打開的網(wǎng)頁源代碼中的結(jié)構(gòu)html 樣式css以及js代碼
最后就可以使用swiper插件
代碼實現(xiàn)
<!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="css/swiper-bundle.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 { width: 100%; height: 100%; } .swiper-slide { 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; } .swiper-slide img { display: block; width: 100%; height: 100%; object-fit: cover; } </style> </head> <body> <!-- Swiper --> <div class="swiper mySwiper"> <div class="swiper-wrapper"> <div class="swiper-slide">Slide 1</div> <div class="swiper-slide">Slide 2</div> <div class="swiper-slide">Slide 3</div> <div class="swiper-slide">Slide 4</div> <div class="swiper-slide">Slide 5</div> <div class="swiper-slide">Slide 6</div> <div class="swiper-slide">Slide 7</div> <div class="swiper-slide">Slide 8</div> <div class="swiper-slide">Slide 9</div> </div> </div> <!-- Swiper JS --> <script src='js/swiper-bundle.min.js'></script> <!-- Initialize Swiper --> <script> var swiper = new Swiper(".mySwiper", {}); </script> </body> </html>
最后如果想改變Swiper插件的API可以閱讀API文檔,然后結(jié)合項目更改
總結(jié)
本篇文章就到這里了,希望能夠給你帶來幫助,也希望您能夠多多關(guān)注腳本之家的更多內(nèi)容!
相關(guān)文章
關(guān)于foreach循環(huán)中遇到的問題小結(jié)
這篇文章主要介紹了關(guān)于foreach循環(huán)中遇到的問題總結(jié),非常不錯,具有參考借鑒價值,需要的朋友可以參考下2017-05-05googlemap 之 javascript實現(xiàn)方法
googlemap 之 javascript實現(xiàn)方法...2007-01-01