Controls image scrolling from left to right

Source: Internet
Author: User

Jquery encapsulates a plug-in that controls the left and right scrolling of images:

<! Doctype HTML> <Style> * {padding: 0; margin: 0; List-style: None} IMG {border: None} # IMG-slider, # img-slider-2 {position: relative; width: 560px; Height: 80px ;}. slider-wrap {width: 480px;/* The width value must be the same as the sum of all Li widths */overflow: hidden; position: relative; Height: 150px; margin-left: 40px ;}. slider-wrap ul {ZOOM: 1; position: absolute; left: 0; top: 0; width: 9999px ;}. slider-wrap ul Li {float: Left; width: 120px; text-align: center; padding: 5px 0 ;}# Prev, # Next {position: absolute; top: 30px; left: 0px; width: 40px }# next {left: auto; Right: 0px} </style>
<SCRIPT type = "text/JavaScript"> $ (function () {$ ("# IMG-slider "). imgscroll (); $ ("# img-slider-2 "). imgscroll () ;});/* plug-in */(function ($) {$. FN. imgscroll = function () {var isdone = false, scrollbox = $ (this), prevbtn = scrollbox. find ("# Prev"), nextbtn = scrollbox. find ("# Next"), imgbox = scrollbox. find ("Ul"), next_over = imgbox. find ("Li "). width () * imgbox. find ("Li "). length, slide_width = $ (". slider-wrap "). width (); Return this. each (function () {function setopacity () {imgbox. animate ({opacity: 1}, 800, function () {isdone = false ;})} function scrollnext () {If (! Isdone & next_over + parseint(imgbox.css ("Left"), 10)> slide_width) {isdone = true; imgbox. animate ({left: "+ =" + "-" + slide_width, opacity: 0.5}, 800, setopacity);} // isdone = false} function scrollprev () {If (! Imgbox. Is (': animated') & parseint(imgbox.css ("Left"), 10 )! = 0) {imgbox. animate ({left: "+ =" + slide_width, // shift left opacity: 0.5}, 800, setopacity) ;}} prevbtn. BIND ('click', scrollprev); // scroll forward to nextbtn. BIND ('click', scrollnext); // scroll back}) (jquery ); </SCRIPT>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.