最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

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

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

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

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

Swiper開源、免費、穩(wěn)定、使用簡單、功能強(qiáng)大,是架構(gòu)移動終端網(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>
  <!-- 如果需要分頁器 -->
  <div class="swiper-pagination"></div>
  
  <!-- 如果需要導(dǎo)航按鈕 -->
  <div class="swiper-button-prev"></div>
  <div class="swiper-button-next"></div>
  
  <!-- 如果需要滾動條 -->
  <div class="swiper-scrollbar"></div>
</div>
導(dǎo)航等組件可以放在container之外

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

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

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

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

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

<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)文章

最新評論

方正县| 邛崃市| 菏泽市| 东乌珠穆沁旗| 仙居县| 栖霞市| 祁东县| 绵竹市| 桂阳县| 饶河县| 旅游| 大港区| 元谋县| 浦城县| 伊金霍洛旗| 乌拉特后旗| 德兴市| 巴彦淖尔市| 图木舒克市| 察隅县| 利辛县| 云浮市| 鞍山市| 阳春市| 泰安市| 石阡县| 庆阳市| 德清县| 美姑县| 府谷县| 邢台市| 南宫市| 北宁市| 新巴尔虎右旗| 汶上县| 西华县| 潜江市| 太白县| 同德县| 岳普湖县| 新宁县|