swipe輪播插件零基礎實用

来源:https://www.cnblogs.com/zmayan/archive/2019/03/06/10483716.html
-Advertisement-
Play Games

此篇博客整理了常用的輪播效果,適用於所有開發人員 swipe是當下相對而言較好用的輪播插件,下麵是博主整理的demo源代碼,可直接上手(備註:需自己手動swipe所需的j和css) 此段代碼總共是有三個詳細效果,並且備註了初始化js對應的html,和使用swipe當中所需要用到的一些小的屬性控制方法 ...


此篇博客整理了常用的輪播效果,適用於所有開發人員

swipe是當下相對而言較好用的輪播插件,下麵是博主整理的demo源代碼,可直接上手(備註:需自己手動swipe所需的j和css)

此段代碼總共是有三個詳細效果,並且備註了初始化js對應的html,和使用swipe當中所需要用到的一些小的屬性控制方法!

這裡就不一一詳解

博客園開通很久,也一直沒時間好好經營自己的博客,第一篇博客,難免細節的地方,排列順序方法,內容介紹肯定難免存在許些問題,博主承諾以後會記錄的越來越優質

希望大家多多指教

  <!DOCTYPE html>
  <html>
  <head>
  <meta charset="utf-8" />
  <title>公用效果</title>
  <link rel="stylesheet" type="text/css" href="css/swiper.min.css"/>
  <script src="js/swiper.min.js"></script>
  <style type="text/css">
  li{
  list-style: none;
  }
  /*分頁器顏色樣式控制*/
  .swiper-pagination-bullet{
  background-color: #8a6b78 !important;
  opacity: 1 !important;
  }
  .swiper-pagination-bullet-active{
  background-color: #e7cccc !important;
  }
  /*前後按鈕控制樣式*/
  .boxleft{
  background: url(img/gift-left.png) no-repeat !important;
  background-size: 100%;
  outline: none;
  }
  .boxright{
  background: url(img/gift-right.png) no-repeat !important;
  background-size: 100%;
  outline: none;
 

}

/*outline: none;屬性可以去除點擊出現邊框*/

  /*.*/
  /*滑鼠移出隱藏按鈕,移入顯示按鈕*/
  .swiper-container .hide{
  opacity:0;
  }
  .swiper-button-next,.swiper-button-prev{
  transition:opacity .5s;
  }
  /*.*/
  /*主圖下滾動*/
  #box {
  width:1200px;
  margin: 0 auto;
  }
  #box .swiper-wrapper{
  margin-top:40px ;
  padding-left: 12px;
  }
  #box ul>li {
  display: inline-block;
  height: 100%;
  box-sizing: border-box;
  }
  #box ul>li>img {
  width: 170px;
  height: 115px;
  }
  /*上下切換控制*/
  .smlbannertop{
  width: 400px;
  }
  .smlbannertop img {
  width: 400px;
  height: 305px;
  }
  .gallery-thumbs .swiper-slide {
  height: 100%;
  opacity: 0.8;
  }
  .gallery-thumbs .swiper-slide-thumb-active {
  opacity: 1;
  }
  .smlbannerall{
  width: 1000px;
  }
  .smlbannerall img {
  width: 176px;
  height: 120px;
  margin: 20px 0px 0 8px;
  }
  </style>
  </head>
  <body>
  <!--top banner-->
  <div class="swiper-container" id="bigbanner">
  <div class="swiper-wrapper">
  <div class="swiper-slide"><img src="img/banner01.jpg"></div>
  <div class="swiper-slide"><img src="img/banner02.jpg"></div>
  <div class="swiper-slide"><img src="img/banner03.jpg"></div>
  </div>
  <!--分頁器-->
  <div class="swiper-pagination bigpagination"></div>
  <!--前進後退按鈕-->
  <div class="swiper-button-prev swiper-button-black bigleft"></div>
  <div class="swiper-button-next swiper-button-black bigright"></div>
  </div>
   
   
  <!--主圖下滾動-->
  <div class="swiper-container" style="width: 1300px; margin: 0 auto;">
  <div class="swiper-container" id="box">
  <ul class="swiper-wrapper">
  <li class="swiper-slide">
  <img src="img/choose1.jpg" />
  </li>
  <li class="swiper-slide">
  <img src="img/choose2.jpg" />
  </li>
  <li class="swiper-slide">
  <img src="img/choose3.jpg" />
  </li>
  <li class="swiper-slide">
  <img src="img/choose4.jpg" />
  </li>
  <li class="swiper-slide">
  <img src="img/choose5.jpg" />
  </li>
  <li class="swiper-slide">
  <img src="img/choose3.jpg" />
  </li>
  </ul>
  </div>
  <div class="swiper-button-prev boxleft"></div>
  <div class="swiper-button-next boxright"></div>
  </div>
   
  <!--切換效果-->
  <div class="swiper-container gallery-top smlbannertop">
  <div class="swiper-wrapper">
  <div class="swiper-slide">
  <img src="img/comrecommend.jpg" />
  </div>
  <div class="swiper-slide">
  <img src="img/comrecommend.jpg" />
  </div>
  <div class="swiper-slide">
  <img src="img/comrecommend.jpg" />
  </div>
  <div class="swiper-slide">
  <img src="img/comrecommend.jpg" />
  </div>
  </div>
  </div>
  <div class="swiper-container gallery-thumbs smlbannerall">
  <ul class="swiper-wrapper">
  <li class="swiper-slide">
  <img src="img/comrecommend01.jpg" />
  </li>
  <li class="swiper-slide">
  <img src="img/comrecommend02.jpg" />
  </li>
  <li class="swiper-slide">
  <img src="img/comrecommend03.jpg" />
  </li>
  <li class="swiper-slide">
  <img src="img/comrecommend04.jpg" />
  </li>
  </ul>
  </div>
   
  <script>
  //topbanner
  var mySwiper = new Swiper('#bigbanner', {
  direction: 'horizontal',
  //是否無限輪播
  loop: true,
  //切換時間
  autoplay: {
  delay: 3000,
  disableOnInteraction: true,//用戶操作swiper之後,是否禁止autoplay。預設為true:停止。
  },
  //過渡時間
  speed: 1300,
  // 如果需要分頁器
  pagination: {
  el: '.bigpagination',
  clickable :true,
  },
  // 如果需要前進後退按鈕
  navigation: {
  nextEl: '.bigright',
  prevEl: '.bigleft',
  },
  //切換效果
  effect:"fade"
  })
  //滑鼠移出隱藏按鈕,移入顯示按鈕
  mySwiper.el.onmouseover=function(){
  mySwiper.navigation.$nextEl.removeClass('hide');
  mySwiper.navigation.$prevEl.removeClass('hide');
  }
  mySwiper.el.onmouseout=function(){
  mySwiper.navigation.$nextEl.addClass('hide');
  mySwiper.navigation.$prevEl.addClass('hide');
  }
   
  //主圖下滾動box
  var swiper = new Swiper('#box', {
  //顯示幾個盒子
  slidesPerView: 6,
  //盒子之間的間距
  spaceBetween: 0,
  autoplayDisableOnInteraction:true,
  loop: true,
  autoplay: {
  delay: 2000
  },
  speed: 800,
  // 如果需要前進後退按鈕
  navigation: {
  nextEl: '.boxright',
  prevEl: '.boxleft',
  },
  });
   
  //切換效果
  var galleryThumbs = new Swiper('.smlbannerall', {
  // 控制顯示幾個
  slidesPerView: 4,
  loop: true,
  loopedSlides: 5, //一般設置為本來slide的個數
  watchSlidesVisibility: true,
  watchSlidesProgress: true,
  });
  var galleryTop = new Swiper('.smlbannertop', {
  spaceBetween: 10,
  loop:true,
  loopedSlides: 5, //一般設置為本來slide的個數
  thumbs: {
  swiper: galleryThumbs,
  },
  });
  </script>
  </body>
  </html>
   

 

 

此效果圖一一貼出


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 採用 flexbox 彈性容器進行佈局,只做練慣用。 瀏覽器打開時切換到手機模式。 樣本地址: http://tpl.zhuamimi.cn/%E6%89%8B%E6%9C%BA%E7%AB%AF%E9%A1%B5%E9%9D%A2-Flexbox/flex%E7%BB%83%E4%B9%A0-%E ...
  • 1.protractor簡介 官網地址:http://www.protractortest.org/ Protractor是一個end-to-end的測試框架,從網路上得到的答案是Protractor是作為Angular JS應用程式的測試框架。它的構建基於Selenium WebDriver之上, ...
  • 1、每個 Vue 實例在被創建時都要經過一系列的初始化過程——例如,需要設置數據監聽、編譯模板、將實例掛載到 DOM 併在數據變化時更新 DOM 等。同時在這個過程中也會運行一些叫做生命周期鉤子的函數,這給了用戶在不同階段添加自己的代碼的機會。 2、本篇將介紹組件創建期間的4個鉤子函數,分別為: ① ...
  • 由於客戶的需求,將js寫出來的一個統計能夠保存到本地。作為碼奴的我只能慢慢搬磚咯!一開始使用的是html2canvas.js。功能是可以實現,但是有缺陷。話不多說開始搞! 1、引入幾個JS庫 ①:jquery 版本還沒試過我用的是3.1.1 (不貼鏈接了,這個要找很容易) ②:dom-to-imag ...
  • 第一種--對象鍵值去重 第二種--splice刪除去重 第三種--利用數組indexOf方法 第四種--數組下標 第五種 第六種 第七種--es6 set 第八種--filter ...
  • 函數內:1,創建AO對象//Activation Object 2,找函數內形參和變數聲明,將其作為AO對象的屬性名,值為undefined。 3,實參賦到AO對象 形參名里 4,在函數體里找函數聲明(函數名),並賦值。 Window內: 1,創建GO對象//Global Object 2,找函數內 ...
  • [TOC] vue.js 學習筆記3——TypeScript 工具 typescript 通過tsconfig.json 文件配置。 可通過gulp 等工具管理項目自動化編譯和運行。 基礎類型 boolean 布爾、number 數字、string 字元串、enum 枚舉、any 任意、void 空 ...
  • 在做項目的時候遇到一個問題,需要新建一個數組,該數組的元素個數為n,且每個元素的值都為0,可以這樣子做: ...
一周排行
    -Advertisement-
    Play Games
  • 示例項目結構 在 Visual Studio 中創建一個 WinForms 應用程式後,項目結構如下所示: MyWinFormsApp/ │ ├───Properties/ │ └───Settings.settings │ ├───bin/ │ ├───Debug/ │ └───Release/ ...
  • [STAThread] 特性用於需要與 COM 組件交互的應用程式,尤其是依賴單線程模型(如 Windows Forms 應用程式)的組件。在 STA 模式下,線程擁有自己的消息迴圈,這對於處理用戶界面和某些 COM 組件是必要的。 [STAThread] static void Main(stri ...
  • 在WinForm中使用全局異常捕獲處理 在WinForm應用程式中,全局異常捕獲是確保程式穩定性的關鍵。通過在Program類的Main方法中設置全局異常處理,可以有效地捕獲並處理未預見的異常,從而避免程式崩潰。 註冊全局異常事件 [STAThread] static void Main() { / ...
  • 前言 給大家推薦一款開源的 Winform 控制項庫,可以幫助我們開發更加美觀、漂亮的 WinForm 界面。 項目介紹 SunnyUI.NET 是一個基於 .NET Framework 4.0+、.NET 6、.NET 7 和 .NET 8 的 WinForm 開源控制項庫,同時也提供了工具類庫、擴展 ...
  • 說明 該文章是屬於OverallAuth2.0系列文章,每周更新一篇該系列文章(從0到1完成系統開發)。 該系統文章,我會儘量說的非常詳細,做到不管新手、老手都能看懂。 說明:OverallAuth2.0 是一個簡單、易懂、功能強大的許可權+可視化流程管理系統。 有興趣的朋友,請關註我吧(*^▽^*) ...
  • 一、下載安裝 1.下載git 必須先下載並安裝git,再TortoiseGit下載安裝 git安裝參考教程:https://blog.csdn.net/mukes/article/details/115693833 2.TortoiseGit下載與安裝 TortoiseGit,Git客戶端,32/6 ...
  • 前言 在項目開發過程中,理解數據結構和演算法如同掌握蓋房子的秘訣。演算法不僅能幫助我們編寫高效、優質的代碼,還能解決項目中遇到的各種難題。 給大家推薦一個支持C#的開源免費、新手友好的數據結構與演算法入門教程:Hello演算法。 項目介紹 《Hello Algo》是一本開源免費、新手友好的數據結構與演算法入門 ...
  • 1.生成單個Proto.bat內容 @rem Copyright 2016, Google Inc. @rem All rights reserved. @rem @rem Redistribution and use in source and binary forms, with or with ...
  • 一:背景 1. 講故事 前段時間有位朋友找到我,說他的窗體程式在客戶這邊出現了卡死,讓我幫忙看下怎麼回事?dump也生成了,既然有dump了那就上 windbg 分析吧。 二:WinDbg 分析 1. 為什麼會卡死 窗體程式的卡死,入口門檻很低,後續往下分析就不一定了,不管怎麼說先用 !clrsta ...
  • 前言 人工智慧時代,人臉識別技術已成為安全驗證、身份識別和用戶交互的關鍵工具。 給大家推薦一款.NET 開源提供了強大的人臉識別 API,工具不僅易於集成,還具備高效處理能力。 本文將介紹一款如何利用這些API,為我們的項目添加智能識別的亮點。 項目介紹 GitHub 上擁有 1.2k 星標的 C# ...