Jquery left and right scroll focus graph banner image move through show up and down button _ jquery

Source: Internet
Author: User
Jquery scroll focus graph banner image, the mouse goes through the display of the top and bottom pages, suitable for the demonstration of pages with relatively large width and height, interested friends can refer to jquery scroll focus graph banner image left and right, move the mouse over the top and bottom pages
Suitable for pages with relatively large width and height

Demo

The Code is as follows:

















The Code is as follows:


@ Charset "UTF-8 ";
Img {border: 0px ;}
. Bannerbox {width: 320px; height: 150px; overflow: hidden; margin: 0px auto ;}
# Focus {width: 320px; height: 150px; clear: both; overflow: hidden; position: relative; float: left ;}
# Focus ul {width: 320px; height: 150px; float: left; position: absolute; clear: both; padding: 0px; margin: 0px ;}
# Focus ul li {float: left; width: 320px; height: 150px; overflow: hidden; position: relative; padding: 0px; margin: 0px ;}
# Focus. preNext {width: 250px; height: 150px; position: absolute; top: 0px; cursor: pointer ;}
# Focus. pre {left: 0; background: url (../images/sprite.png) no-repeat left center ;}
# Focus. next {rightright: 0; background: url (../images/sprite1.png) no-repeat rightright center ;}


Js files

The Code is as follows:


$ (Function (){
Var sWidth = $ ("# focus"). width ();
Var len = $ ("# focus ul li"). length;
Var index = 0;
Var picTimer;
Var btn ="

";
For (var I = 0; I <len; I ++ ){
Btn + = "";
}
Btn + ="

";
$ ("# Focus"). append (btn );
$ ("# Focus. btnBg" 2.16.css ("opacity", 0 );
$ ("# Focus. btn span" example .css ("opacity", 0.4). mouseenter (function (){
Index = $ ("# focus. btn span"). index (this );
ShowPics (index );
}). Eq (0). trigger ("mouseenter ");
$ ("# Focus. preNext" detail .css ("opacity", 0.0). hover (function (){
$ (This). stop (true, false). animate ({"opacity": "0.5"}, 300 );
}, Function (){
$ (This). stop (true, false). animate ({"opacity": "0"}, 300 );
});
$ ("# Focus. pre"). click (function (){
Index-= 1;
If (index =-1) {index = len-1 ;}
ShowPics (index );
});
$ ("# Focus. next"). click (function (){
Index + = 1;
If (index = len) {index = 0 ;}
ShowPics (index );
});
$ ("# Focus ul" ).css ("width", sWidth * (len ));
$ ("# Focus"). hover (function (){
ClearInterval (picTimer );
}, Function (){
PicTimer = setInterval (function (){
ShowPics (index );
Index ++;
If (index = len) {index = 0 ;}
},2800 );
}). Trigger ("mouseleave ");
Function showPics (index ){
Var nowLeft =-index * sWidth;
$ ("# Focus ul"). stop (true, false). animate ({"left": nowLeft}, 300 );
$ ("# Focus. btn span "). stop (true, false ). animate ({"opacity": "0.4"}, 300 ). eq (index ). stop (true, false ). animate ({"opacity": "1"}, 300 );
}
});

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.