$(document).ready(function (){/*=============Author:GinoBlog:http://HdhCmsTestcnblogs测试数据/ginowang42Thanks:@Blue--http://HdhCmsTestzhinengshe测试数据/video.html#1Name:jQuery插件图片左右无缝滚动Arguments: @leftBtn:向左滚动按钮DOM引用 @rightBtn:向右滚动按钮DOM引用 @speed:滚动速度(每次滚动像素数)CSS keyed Attribute: #noSeamScroll{position:relative;overflow:hidden;} #noSeamScroll ul{position:absolute;} #noSeamScroll ul li {float:left;} ===============*/ $.fn.extend({noSeamScroll:function (leftBtn,rightBtn,speed){ var timeFlag = speed = speed || 4;; var timer = null; var _this = this;//把this重新保存在一个私有变量里面,以防止setInterval误把this指向了window this.oUl = $("ul",this); this.oUl.html(this.oUl.html() + this.oUl.html());//把li复制一份 this.oLis = $("ul li",this);//之后再变量保存li的全部节点 this.oUl.width(this.oLis.eq(0).outerWidth(true)*this.oLis.length + "px"); var fnMove = function (){ $("ul",_this).css("left",function (){ if ($(this).position().left > 0){//这里的this指的是$("ul",element) return -$(this).outerWidth(true)/2 + "px"; } if ($(this).position().left *{margin:0;padding:0;} #noSeamScroll{width:752px;height:108px;margin:20px auto;position:relative;overflow:hidden;} #noSeamScroll ul{position:absolute;list-style:none;} #noSeamScroll ul li {float:left;width:178px;height:108px;margin-right:10px;} 向左移动向右移动
查看更多关于div+css+jQuery图片横向滚动代码(带左右点击按钮)_html/css_WEB-ITnos的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did102247