失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > div+css+jQuery图片横向滚动代码(带左右点击按钮)【HTML】

div+css+jQuery图片横向滚动代码(带左右点击按钮)【HTML】

时间:2022-06-18 06:11:08

相关推荐

div+css+jQuery图片横向滚动代码(带左右点击按钮)【HTML】

web前端|html教程

div+css+jQuery图片横向滚动代码(带左右点击按钮)

web前端-html教程

首先感谢Blue老师的javascript教学,给了我很多的启发,这是我在看完10 – 定时器的使用 – 2这节视频后,自己试着用jQuery重新改写了一下代码,感觉至少比百度搜出来的那一坨靠谱多了,上代码:

h5传奇 合击源码,ubuntu不加载驱动,tomcat添加到快速启动,天猫爬虫python,php开发技术外包驻场报价,广州seo关lzw

$(document).ready(function (){/*=============Author:GinoBlog:/ginowang42Thanks:@Blue--/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 < -$(this).outerWidth(true)/2 ){ return "0px";}return $(this).position().left + timeFlag + "px"; }) } timer = setInterval(fnMove,30);this.mouseover(function () {clearInterval(timer);}); this.mouseout(function () {timer = setInterval(fnMove,30)});leftBtn.click(function (){ clearInterval(timer); timeFlag = -speed; timer = setInterval(fnMove,30); }) rightBtn.click(function (){ clearInterval(timer); timeFlag = speed; timer = setInterval(fnMove,30); }) } }); //test $("#noSeamScroll").noSeamScroll($("#leftArr"),$("#rightArr"),2); }) *{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;} 向左移动向右移动

强制转发的源码,vscode透明磨砂主题,ubuntu建立帐户,tomcat8.5.5,易语言sqlite查找语句,前端查询表格一般用什么框架,花里特别小的黑色爬虫,php 随机汉字,金华seo优化优势,获取网站php文件,网页打不开显示502 bad gateway,系统登录页面模板lzw

如果觉得《div+css+jQuery图片横向滚动代码(带左右点击按钮)【HTML】》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。