最近在使用的一个移动触摸滑动插件Swiper,功能很强大,跟之前的那个swipe.JS相比,同时支持在PC端滑动,支持上下方向滑动,支持多张图片滑动,支持多屏滑动,凡是你想得到的几乎都可以实现。最近作者还更新了3.0版本,优先支持ios和最新版的Android移动端。

下载代码

可以在github上下载:https://github.com/nolimits4web/Swiper/

或者有bower的,直接安装 $ bower install swiper

使用方法

swiper支持纯jsjQuery两种方式

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

jQuery方式

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

html代码

<!-- Slider main container -->
<div class="swiper-container">
<!-- Additional required wrapper -->
<div class="swiper-wrapper">
<!-- Slides -->
<div class="swiper-slide">Slide 1</div>
<div class="swiper-slide">Slide 2</div>
<div class="swiper-slide">Slide 3</div>
...
</div>
<!-- If we need pagination -->
<div class="swiper-pagination"></div> <!-- If we need navigation buttons -->
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div> <!-- If we need scrollbar -->
<div class="swiper-scrollbar"></div>
</div>

CSS代码

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

js代码

<script>
var mySwiper = new Swiper ('.swiper-container', {
// Optional parameters
direction: 'vertical',
loop: true, // If we need pagination
pagination: '.swiper-pagination', // Navigation arrows
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev', // And if we need scrollbar
scrollbar: '.swiper-scrollbar',
})
</script>

jQuery代码

$(document).ready(function () {

//initialize swiper when document ready
var mySwiper = new Swiper ('.swiper-container', {
// Optional parameters
direction: 'vertical',
loop: true
})
});

最新文章

  1. jquery ajax success 函数 异步调用方法中不能给全局变量赋值的原因及解决办法
  2. python---IO多路复用
  3. PDO 学习与使用 ( 一 ) :PDO 对象、exec 方法、query 方法与防 SQL 注入
  4. floor舍去法取整
  5. 高效Count
  6. git引用^和~的区别
  7. POJ2103 Jackpot
  8. linux下使用mutt发送带附件的邮件
  9. 使用httpclient抓取时,netstat 发现很多time_wait连接
  10. 如何将经纬度利用Google Map API显示C# VS2005 Sample Code
  11. SourceTree使用方法介绍
  12. Redis 数据结构与内存管理策略(上)
  13. js 获取二级域名
  14. 一个简单的java程序,用于RabbitMQ日志监控
  15. 移动端根元素(html)的设置
  16. vue自学入门-3(vue第一个例子)
  17. Runloop的再学习之浅析(一)
  18. 解决web项目存在多个log4j.properties配置文件,导致日志级别配置不生效问题
  19. c# GC 新典型
  20. Html - Table 表头固定和 tbody 设置 height 在IE不起作用的解决

热门文章

  1. 微信小程序 --- 动画
  2. Tomcat部署静态网站
  3. 您好,前端使用https,后端使用https是会有冲突的情况,所以默认后端都是http 负载均衡即可管理证书,不需要在后端ECS上绑定证书。
  4. 修改hosts搭建本地站点
  5. My Emacs Writing Setup
  6. git-【八】多人协作
  7. Scala的类与类型
  8. Alpine Linux配置使用技巧【一个只有5M的操作系统(转)】
  9. Struct2小结:
  10. array2xml xml2array