欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Swiper 4.x 使用方法(移動(dòng)端網(wǎng)站的內(nèi)容觸摸滑動(dòng))

 更新時(shí)間:2018年05月17日 22:05:07   投稿:mdxy-dxy  
Swiper是純javascript打造的滑動(dòng)特效插件,面向手機(jī)、平板電腦等移動(dòng)終端,這里為大家簡(jiǎn)單介紹一下Swiper4的用法,需要的朋友可以參考下

Swiper常用于移動(dòng)端網(wǎng)站的內(nèi)容觸摸滑動(dòng)

Swiper是純javascript打造的滑動(dòng)特效插件,面向手機(jī)、平板電腦等移動(dòng)終端。

Swiper能實(shí)現(xiàn)觸屏焦點(diǎn)圖、觸屏Tab切換、觸屏多圖切換等常用效果。

Swiper開(kāi)源、免費(fèi)、穩(wěn)定、使用簡(jiǎn)單、功能強(qiáng)大,是架構(gòu)移動(dòng)終端網(wǎng)站的重要選擇!

1.首先加載插件,需要用到的文件有swiper.min.js和swiper.min.css文件??上螺dSwiper文件或使用CDN。

<!DOCTYPE html>
<html>
<head>
  ...
  <link rel="stylesheet" href="path/to/swiper.min.css" rel="external nofollow" >
</head>
<body>
  ...
  <script src="path/to/swiper.min.js"></script>
</body>
</html>

2.HTML內(nèi)容。

<div class="swiper-container">
  <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>
  <!-- 如果需要分頁(yè)器 -->
  <div class="swiper-pagination"></div>
  
  <!-- 如果需要導(dǎo)航按鈕 -->
  <div class="swiper-button-prev"></div>
  <div class="swiper-button-next"></div>
  
  <!-- 如果需要滾動(dòng)條 -->
  <div class="swiper-scrollbar"></div>
</div>
導(dǎo)航等組件可以放在container之外

3.你可能想要給Swiper定義一個(gè)大小,當(dāng)然不要也行。

.swiper-container {
  width: 600px;
  height: 300px;
} 

4.初始化Swiper:最好是挨著</body>標(biāo)簽

<script>    
 var mySwiper = new Swiper ('.swiper-container', {
  direction: 'vertical',
  loop: true,
  
  // 如果需要分頁(yè)器
  pagination: {
   el: '.swiper-pagination',
  },
  
  // 如果需要前進(jìn)后退按鈕
  navigation: {
   nextEl: '.swiper-button-next',
   prevEl: '.swiper-button-prev',
  },
  
  // 如果需要滾動(dòng)條
  scrollbar: {
   el: '.swiper-scrollbar',
  },
 })    
 </script>
</body>

如果不能寫(xiě)在HTML內(nèi)容的后面,則需要在頁(yè)面加載完成后再初始化(不推薦)。

<script type="text/javascript">
window.onload = function() {
 ...
}
</script>

或者這樣(Jquery和Zepto)

<script type="text/javascript">
$(document).ready(function () {
 ...
})
</script>

5.完成。恭喜你,現(xiàn)在你的Swiper應(yīng)該已經(jīng)能正常切換了。

相關(guān)文章

最新評(píng)論