


div css jQuery image horizontal scrolling code (with left and right click buttons)_html/css_WEB-ITnose
First of all, I would like to thank Mr. Blue for his javascript tutorial, which gave me a lot of inspiration. After watching the video section 10 - Use of timers - 2, I tried to rewrite the code with jQuery. It feels at least more reliable than the one found on Baidu. Here’s the code:
<!DOCTYPE HTML><html lang="en-US"><head> <meta charset="UTF-8"> <title></title> <script type="text/javascript" src = "jquery_v1.7.2.js"></script> <script type="text/javascript">$(document).ready(function (){/*=============Author:GinoBlog:http://www.cnblogs.com/ginowang42Thanks:@Blue--http://www.zhinengshe.com/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); }) </script> <style type="text/css"> *{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;} </style></head><body><a href="javascript:;" id="leftArr">向左移动</a><a href="javascript:;" id="rightArr">向右移动</a> <div id = "noSeamScroll"> <ul> <li><img src="images/1.jpg" alt="" /></li> <li><img src="images/2.jpg" alt="" /></li> <li><img src="images/3.jpg" alt="" /></li> <li><img src="images/4.jpg" alt="" /></li> </ul> </div></body></html>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

The article discusses the viewport meta tag, essential for responsive web design on mobile devices. It explains how proper use ensures optimal content scaling and user interaction, while misuse can lead to design and accessibility issues.

The article discusses the <iframe> tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.

HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.
