栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > Web开发 > JavaScript

jQuery bxCarousel实现图片滚动切换效果示例代码

JavaScript 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

jQuery bxCarousel实现图片滚动切换效果示例代码

BxCarousel是一个具有众多配置且易用的Jquery图片滚动插件,特征主要有:
◆ 可以指定显示的元素总数
◆ 可以指定每次滚动的元素个数
◆ 自动播放模式
◆ 前一张/后一张按钮控制图片流动
参数含义
display_num:显示元素的数量,几张图片
move:单击左右控制键时,移动的元素个数,此处为移动2张图片
prev_image:上一元素按钮图片
next_image:下一元素按钮图片
margin:图片之间的间隙,一般设为10px
auto:自动滚动效果
controls:是否显示左右控制按钮,此处为false,表示不显示左右控制按钮
auto_hover:鼠标悬停到轮播区域时,是否停止图片轮播
BxCarousel使用和配置
首先HTML代码需要符合以下格式
复制代码 代码如下:

  • first piece of content

  • second piece of content

  • third piece of content

  • fourth piece of content

  • bxCarousel can accept an unlimited number of elements



jQuery代码需要符合以下格式
复制代码 代码如下:
$(document).ready(function(){
$('ul').bxCarousel({
display_num: 4, // number of elements to be visible
move: 4, // number of elements to the shift the slides
speed: 500, // number in milliseconds it takes to finish slide animation
margin:0, // right margin to be applied to each
  • element (in pixels, although do not include "px")
    auto: false, // automatically play slides without a user click
    auto_interval: 2000, // the amount of time in milliseconds between each auto animation
    auto_dir: 'next', // direction of auto slideshow (options: 'next', 'prev')
    auto_hover: false, // determines if the slideshow will stop when user hovers over slideshow
    next_text: 'next', // text to be used for the 'next' control
    next_image: '', // image to be used for the 'next' control
    prev_text: 'prev', // text to be used for the 'prev' control
    prev_image: '', // image to be used for the 'prev' control
    controls: true // determines if controls will be displayed
    });
    });

    div.bx_container和div.bx_wrap等html元素是js生成加上的,在使用bxCarousel插件时,为了达到视觉美感,要记得为div.bx_container和div.bx_wrap及其内部子元素设定需要的CSS Style。
    还有注意的是,
    bxCarousel是个无限循环机制,不停的点击next按钮看看html发生了什么变化!!
    bxCarousel不只针对图片,对其他任何html元素均起作用。
    如果开启auto属性,注意一定要保证speed属性值小于持续时间。
    实例代码
    复制代码 代码如下:













    .pic, .vd{
    width:200px;
    height:200px;
    margin:0 auto;
    }
    .pic a, .vd a{
    display:block;
    width:200px;
    height:200px;
    text-align:center;
    margin:0 auto;
    }
    .pic{
    background:url("http://i0.sinaimg.cn/home/2013/0513/U2727P30DT20130513082202.jpg") no-repeat scroll 0 0 transparent;
    }
    .vd{
    background:url("http://i0.sinaimg.cn/home/2013/0512/U1345P30DT20130512114119.jpg") no-repeat scroll 0 0 transparent;
    }
    .nav,.main,.imgcollc ,.footer{
    width:910px;
    margin:0 auto;
    text-align:center;
    }

    a {color: #424242;text-decoration: none;}
    ul,li,ol{padding:0;margin:0;list-style:none;}
    .bx_wrap {margin-left: 30px; margin-top:10px;}
    .bx_wrap ul img { border: 2px solid #ddd; }
    .bx_wrap ul li{text-align:center;float:left;width:140px;height:119px;overflow:hidden;}
    .bx_wrap ul li a:hover{text-decoration:none; color:#f30;}
    .bx_wrap a.prev {width:20px;height:24px;line-height:24px;outline-style:none;outline-width: 0; position:absolute; top:45px; left:5px; text-indent:-999em; background: url(img/arr_left.gif) no-repeat;}
    .bx_wrap a.next {width:20px;height:24px;line-height:24px; left:623px;position: absolute; top:45px; text-indent:-999em; background:url('img/arr_right.gif') no-repeat;}
    .demo {width: 650px;height: 134px;margin: 40px auto;position: relative;border: 1px solid #d3d3d3;overflow:hidden;
    }







    jQuery实现的视频窗口伸缩、图片滚动切换效果











    • 图片1


    • 图片2


    • 图片3


    • 图片4


    • 图片5


    • 图片6


    • 图片7


    • 图片1


    • 图片2


    • 图片3


    • 图片4


    • 图片5


    • 图片6


    • 图片7






    • 图片1


    • 图片2


    • 图片3


    • 图片4


    • 图片5


    • 图片6




    Mobile



    本实例中同时实现了灯箱效果。由于采用videobox插件,对于图片和视频都支持。很多灯箱效果的脚本和插件,比如jQuery Lightbox Plugin,Videobox, MooslideBox,,Shadowbox和 LightWindow 等等。
    Videobox是一个只有6k大小的脚本,用于在页面中显示视频。Videobox使用swfobject来嵌入Flash。视频可以来自Youtube、metacafe、Google Video、iFilm和自己设置的Flash。如果你要达到效果,必须使用videobox.js,mootools.js和swfobject脚.js这个三个脚本。

    类似滚动滑动的插件还有bxSlider 等等,bxSlider是一个 jQuery 的插件,它可以实现 Slider 和滚动效果。这个插件使用非常简单,并且大小只有 8kb,非常轻量级,所以非常适合在站点和博客中使用。

  • 转载请注明:文章转载自 www.mshxw.com
    本文地址:https://www.mshxw.com/it/111303.html
    我们一直用心在做
    关于我们 文章归档 网站地图 联系我们

    版权所有 (c)2021-2022 MSHXW.COM

    ICP备案号:晋ICP备2021003244-6号