ResponsiveSlides.js是一个展示同一容器内图片的轻量级响应式jQuery幻灯片插件(tiny responsive slideshow jQuery plugin)。它支持包括IE6在内的几乎所有的浏览器,在IE6中还支持最大宽度属性,但在其它浏览器中并不原生支持。你需要做的只是链接jquery并且把图片裁剪为相同大小。

工具/原料

 
  • 笔记本电脑或是台式机
  • 互联网
  • ResponsiveSlides

方法/步骤

 
  1. 1

    在github上下载ResponsiveSlides.js,如下图所示。

  2. 2

    解压ResponsiveSlides.js-master.zip文件,工程目录如下图所示。

  3. 3

    新建工程目录,将responsiveslides.css、responsiveslides.min.js拷贝进来,分别放在新建的css和js文件夹。

  4. 4

    引入文件

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

    <script src="responsiveslides.min.js"></script>

  5. 5

    添加HTML标记

    <ul class="rslides">

    <li><img src="1.jpg" alt=""></li>

    <li><img src="2.jpg" alt=""></li>

    <li><img src="3.jpg" alt=""></li>

    </ul>

  6.  

    添加CSS

    .rslides {

    position: relative;

    list-style: none;

    overflow: hidden;

    width: 100%;

    padding: 0;

    margin: 0;

    }

    .rslides li {

    -webkit-backface-visibility: hidden;

    position: absolute;

    display: none;

    width: 100%;

    left: 0;

    top: 0;

    }

    .rslides li:first-child {

    position: relative;

    display: block;

    float: left;

    }

    .rslides img {

    display: block;

    height: auto;

    float: left;

    width: 100%;

    border: 0;

    }

  7.  

    调用API

    <script>

    $(function() {

    $(".rslides").responsiveSlides();

    });

    </script>

  8.  

    API参数:

    $(".rslides").responsiveSlides({

    auto: true,             // Boolean: 设置是否自动播放, true or false

    speed: 500,            // Integer: 动画持续时间,单位毫秒

    timeout: 4000,          // Integer: 图片之间切换的时间,单位毫秒

    pager: false,           // Boolean: 是否显示页码, true or false

    nav: false,             // Boolean: 是否显示左右导航箭头(即上翻下翻), true or false

    random: false,          // Boolean: 随机幻灯片顺序, true or false

    pause: false,           // Boolean: 鼠标悬停到幻灯上则暂停, true or false

    pauseControls: true,    // Boolean: 悬停在控制板上则暂停, true or false

    prevText: "Previous",   // String: 往前翻按钮的显示文本

    nextText: "Next",       // String: 往后翻按钮的显示文本

    maxwidth: "",           // Integer: 幻灯的最大宽度

    navContainer: "",       // Selector: Where controls should be appended to, default is after the 'ul'

    manualControls: "",     // Selector: 声明自定义分页导航

    namespace: "rslides",   // String: 修改默认的容器名称

    before: function(){},   // Function: 回调之前的参数

    after: function(){}     // Function: 回调之后的参数

  9.  

    浏览器支持:

    Internet Explorer 6,7,8,9

    Firefox 3,6,8,11

    Safari 5,5.1

    Chrome 15,20

    Opera 11,11.6

    iOS Safari

    Symbian 3 Webkit

    Opera Mobile 10.1

    Opera Mini for iOS

    IE7, IE9 Mobile

    Firefox Mobile

    Android 2.3+

    Kindle browser

  10.  

    特点:

    1.文件较小(通过缩减和gz压缩只有792字节)

    2.功能简单(ResponsiveSlides.js只支持三种模式:图片自动淡出淡入和使用页码标签,或者左右来手动切换图片。)

  11.  

    demo.css

    * {

    margin: 0;

    padding: 0;

    }

    html {

    background: #222 url("images/bg.png") repeat;

    }

    body {

    _width: 70%;

    color: #888;

    font: 14px/20px Helvetica, Arial, sans-serif;

    margin: 20px auto 0;

    max-width: 800px;

    text-align: center;

    text-shadow: 0 -2px 1px #000;

    -webkit-font-smoothing: antialiased;

    }

    h1 {

    font: 40px/60px "Helvetica Neue", Helvetica, Arial, sans-serif;

    color: #fff;

    font-weight: 200;

    }

    h2 {

    font: 16px/20px "Helvetica Neue", Helvetica, Arial, sans-serif;

    margin-bottom: 40px;

    }

    #wrapper {

    padding: 20px;

    }

    p,h3,h4,pre {

    text-align: left;

    max-width: 540px;

    margin: 0 auto 20px;

    }

    .rslides {

    margin: 0 auto 40px;

    }

    #slider2,

    #slider3 {

    box-shadow: none;

    -moz-box-shadow: none;

    -webkit-box-shadow: none;

    margin: 0 auto;

    }

    .rslides_tabs {

    list-style: none;

    padding: 0;

    background: rgba(0,0,0,.25);

    box-shadow: 0 0 1px rgba(255,255,255,.3), inset 0 0 5px rgba(0,0,0,1.0);

    -moz-box-shadow: 0 0 1px rgba(255,255,255,.3), inset 0 0 5px rgba(0,0,0,1.0);

    -webkit-box-shadow: 0 0 1px rgba(255,255,255,.3), inset 0 0 5px rgba(0,0,0,1.0);

    font-size: 18px;

    list-style: none;

    margin: 0 auto 50px;

    max-width: 540px;

    padding: 10px 0;

    text-align: center;

    width: 100%;

    }

    .rslides_tabs li {

    display: inline;

    float: none;

    margin-right: 1px;

    }

    .rslides_tabs a {

    width: auto;

    line-height: 20px;

    padding: 9px 20px;

    height: auto;

    background: transparent;

    display: inline;

    }

    .rslides_tabs li:first-child {

    margin-left: 0;

    }

    .rslides_tabs .rslides_here a {

    background: rgba(255,255,255,.1);

    color: #fff;

    font-weight: bold;

    }

    a {

    color: #fff;

    text-decoration: none;

    }

    #download {

    background: #333;

    background: rgba(255,255,255,.1);

    border: 1px solid rgba(255,255,255,.1);

    border-radius: 5px;

    -moz-border-radius: 5px;

    -webkit-border-radius: 5px;

    display: block;

    font-size: 20px;

    font-weight: bold;

    margin: 60px auto;

    max-width: 500px;

    padding: 20px;

    }

    #download:hover {

    background: rgba(255,255,255,.15);

    }

    .footer {

    font-size: 11px;

    }

    /* Callback example */

    h3 {

    font: 20px/30px "Helvetica Neue", Helvetica, Arial, sans-serif;

    text-align: center;

    color: #fff;

    }

    .events {

    list-style: none;

    }

    .callbacks_container {

    margin-bottom: 50px;

    position: relative;

    float: left;

    width: 100%;

    }

    .callbacks {

    position: relative;

    list-style: none;

    overflow: hidden;

    width: 100%;

    padding: 0;

    margin: 0;

    }

    .callbacks li {

    position: absolute;

    width: 100%;

    left: 0;

    top: 0;

    }

    .callbacks img {

    display: block;

    position: relative;

    z-index: 1;

    height: auto;

    width: 100%;

    border: 0;

    }

    .callbacks .caption {

    display: block;

    position: absolute;

    z-index: 2;

    font-size: 20px;

    text-shadow: none;

    color: #fff;

    background: #000;

    background: rgba(0,0,0, .8);

    left: 0;

    right: 0;

    bottom: 0;

    padding: 10px 20px;

    margin: 0;

    max-width: none;

    }

    .callbacks_nav {

    position: absolute;

    -webkit-tap-highlight-color: rgba(0,0,0,0);

    top: 52%;

    left: 0;

    opacity: 0.7;

    z-index: 3;

    text-indent: -9999px;

    overflow: hidden;

    text-decoration: none;

    height: 61px;

    width: 38px;

    background: transparent url("themes/themes.gif") no-repeat left top;

    margin-top: -45px;

    }

    .callbacks_nav:active {

    opacity: 1.0;

    }

    .callbacks_nav.next {

    left: auto;

    background-position: right top;

    right: 0;

    }

    #slider3-pager a {

    display: inline-block;

    }

    #slider3-pager img {

    float: left;

    }

    #slider3-pager .rslides_here a {

    background: transparent;

    box-shadow: 0 0 0 2px #666;

    }

    #slider3-pager a {

    padding: 0;

    }

    @media screen and (max-width: 600px) {

    h1 {

    font: 24px/50px "Helvetica Neue", Helvetica, Arial, sans-serif;

    }

    .callbacks_nav {

    top: 47%;

    }

    }

  12.  

    案例1

    <!DOCTYPE html>

    <html>

    <head>

    <meta charset="utf-8">

    <title>ResponsiveSlides.js &middot; Responsive jQuery slideshow</title>

    <meta name="viewport" content="width=device-width,initial-scale=1">

    <link rel="stylesheet" href="../responsiveslides.css">

    <link rel="stylesheet" href="demo.css">

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

    <script src="../responsiveslides.min.js"></script>

    <script>

    // You can also use "$(window).load(function() {"

    $(function () {

    // Slideshow 1

    $("#slider1").responsiveSlides({

    maxwidth: 800,

    speed: 800

    });

    });

    </script>

    </head>

    <body>

    <div id="wrapper">

    <h1>ResponsiveSlides.js</h1>

    <h2>Simple &amp; lightweight responsive slideshow plugin (in 1kb)</h2>

    <!-- Slideshow 1 -->

    <ul id="slider1">

    <li><img src="data:images/1.jpg" alt=""></li>

    <li><img src="data:images/2.jpg" alt=""></li>

    <li><img src="data:images/3.jpg" alt=""></li>

    </ul>

    </div>

    </body>

    </html>

  13.  

    案例1运行效果,如下图所示。

  14.  

    案例2

    <!DOCTYPE html>

    <html>

    <head>

    <meta charset="utf-8">

    <title>ResponsiveSlides.js &middot; Responsive jQuery slideshow</title>

    <meta name="viewport" content="width=device-width,initial-scale=1">

    <link rel="stylesheet" href="../responsiveslides.css">

    <link rel="stylesheet" href="demo.css">

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

    <script src="../responsiveslides.min.js"></script>

    <script>

    // You can also use "$(window).load(function() {"

    $(function () {

    // Slideshow 2

    $("#slider2").responsiveSlides({

    auto: false,

    pager: true,

    speed: 300,

    maxwidth: 540

    });

    });

    </script>

    </head>

    <body>

    <div id="wrapper">

    <h1>ResponsiveSlides.js</h1>

    <h2>Simple &amp; lightweight responsive slideshow plugin (in 1kb)</h2>

    <!-- Slideshow 2 -->

    <ul id="slider2">

    <li><a href="#"><img src="data:images/1.jpg" alt=""></a></li>

    <li><a href="#"><img src="data:images/2.jpg" alt=""></a></li>

    <li><a href="#"><img src="data:images/3.jpg" alt=""></a></li>

    </ul>

    </div>

    </body>

    </html>

  15.  

    案例2,运行效果图,如下图所示。

    END

注意事项

 
  • ResponsiveSlides.js依赖JQuery,需要引入JQuery库
  • ResponsiveSlides.js实现了响应式

jQuery常用插件大全(9)ResponsiveSlides插件的更多相关文章

  1. 常用JQUERY插件大全

    jQuery内容滚动插件-BoxSlider jQuery artDialog对话框插件 移动端日期选择组件 图像延迟加载库Echo.js 轮播图FlexSlider插件 Slick.js幻灯片使用方 ...

  2. jQuery常用插件大全

    1.五星级插件jRating 详细文档介绍:http://www.myjqueryplugins.com/jquery-plugin/jrating 2.图片展示插件Swiper和Slider swi ...

  3. jQuery常用插件

    jQuery UI插件简介: jQuery UI是以 jQuery 为基础的开源 JavaScript 网页用户界面代码库.包含底层用户交互.动画.特效和可更换主题的可视控件.我们可以直接用它来构建具 ...

  4. 转 jquery插件--241个jquery插件—jquery插件大全

    241个jquery插件—jquery插件大全 jquery插件jqueryautocompleteajaxjavascriptcoldfusion jQuery由美国人John Resig创建,至今 ...

  5. jQuery常用插件与jQuery使用validation插件实现表单验证实例

    jQuery常用插件 1,jQuery特别容易扩展,开发者可以基于jQuery开发一些扩展动能 2,插件:http://plugins.jquery.com 3,超厉害的插件:validation . ...

  6. jquery插件大全

    241个jquery插件—jquery插件大全 免费JQuery插件 推荐12款非常有用的流行 jQuery 插件

  7. 《JQuery常用插件教程》系列分享专栏

    <JQuery常用插件教程>已整理成PDF文档,点击可直接下载至本地查阅https://www.webfalse.com/read/201719.html 文章 使用jquery插件实现图 ...

  8. 编写jquery常用插件的基本格式

    写jquery插件需要明白的那些知识点 1.jquery中$是神马?$.fn又是神马? 稍微有jquery经验的都知道在jquery中$等价于jQuery,在控制台一试便知: 我们在jquery(1. ...

  9. 三、jQuery--jQuery基础--jQuery基础课程--第9章 jQuery 常用插件

    1.表单验证插件——validate 该插件自带包含必填.数字.URL在内容的验证规则,即时显示异常信息,此外,还允许自定义验证规则,插件调用方法如下:$(form).validate({option ...

  10. 网站开发常用jQuery插件总结(11)折叠插件Akordeon

    实现折叠菜单,可以完全不使用插件.如果使用jquery的话,实现起来也比较简单,我们只需要定义折叠菜单的样式,然后使用jquery中的渐隐渐现就可以了.如果我们自己写折叠菜单,可以方便的使用我们自己的 ...

随机推荐

  1. [转发]Android 系统稳定性 - ANR(一)

    文章都为原创,转载请注明出处,未经允许而盗用者追究法律责任.很久之前写的了,留着有点浪费,共享之.编写者:李文栋  http://rayleeya.iteye.com/blog/1955652 如果你 ...

  2. POSTMAN编写文档

    第一步:创建文件夹: 同时创建全局变量: 第二步:创建分组文件夹: 第三步:添加请求: 类似正常调试,然后多了一步保存: 保存: 请求方式发生相应变化,同时颜色也发生变化,说明保存成功: ====== ...

  3. PAT (Advanced Level) 1086. Tree Traversals Again (25)

    入栈顺序为先序遍历,出栈顺序为中序遍历. #include<cstdio> #include<cstring> #include<cmath> #include&l ...

  4. [bzoj1110][POI2007]砝码Odw_贪心

    bzoj-1110 POI-2007 砝码Odw 参考博客:http://hzwer.com/4761.html 题目大意:在byteotian公司搬家的时候,他们发现他们的大量的精密砝码的搬运是一件 ...

  5. Atcoder 3857 Median Sum

    Problem Statement You are given N integers A1, A2, ..., AN. Consider the sums of all non-empty subse ...

  6. Java8期间及持续时间

    原文:http://www.yiibai.com/java8/java8_periodduration.html 使用Java8,两个专门类引入来处理时间差. Period - 处理有关基于时间的日期 ...

  7. UICollectionView 讲解

    什么是UICollectionView UICollectionView是一种新的数据展示方式,简单来说可以把他理解成多列的UITableView(请一定注意这是 UICollectionView的最 ...

  8. Python基础语法08--MySql应用

    python操作mysql数据库 Python 标准数据库接口为 Python DB-API,Python DB-API为开发人员提供了数据库应用编程接口. DB-API 是一个规范. 它定义了一系列 ...

  9. es中插入数据

    es中插入数据 学习了:https://www.imooc.com/video/15769/0 分为指定Id和自动生成Id两种: 1,指定Id使用PUT操作 PUT http://127.0.0.1: ...

  10. 使用FMDB多线程訪问数据库,及database is locked的问题

    今天最终攻克了多线程同一时候訪问数据库时,报数据库锁定的问题.错误信息是: Unknown error finalizing or resetting statement (5: database i ...