ตัวอย่าง
CSS ตัวอย่าง
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | <style type= "text/css" > div#containSlidebanner{ margin : 0 ; padding : 0 ; width : 500px ; height : 250px ; overflow : hidden ; background-color : #FFFF33 ; } ul#slideBanner,ul#slideBanner li{ margin : 0 ; padding : 0 ; list-style : none ; float : left ; } ul#slideBanner{ width : 550px ; white-space : nowrap ; } ul#slideBanner li{ width : 100px ; height : 250px ; } li#banner 1 { background-color : #CC99CC ; } li#banner 2 { background-color : #99CC66 ; } li#banner 3 { background-color : #33CC99 ; } li#banner 4 { background-color : #FFFF66 ; } li#banner 5 { background-color : #CCFF00 ; } </style> |
HTML Code ตัวอย่าง
1 2 3 4 5 6 7 8 9 | < div id = "containSlidebanner" > < ul id = "slideBanner" > < li id = "banner1" ></ li > < li id = "banner2" ></ li > < li id = "banner3" ></ li > < li id = "banner4" ></ li > < li id = "banner5" ></ li > </ ul > </ div > |
jQuery Code ตัวอย่าง
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | <script type= "text/javascript" src= "jquery-1.4.1.min.js" ></script> <script type= "text/javascript" > $( function (){ $( "ul#slideBanner li" ).hover( function (index){ $( this ).animate({ width: "300px" },200); $( this ).prevAll( "li" ).animate({ width: "50px" },200); $( this ).nextAll( "li" ).animate({ width: "50px" },200); }, function (){ $( this ).stop( true ); $( this ).siblings( "li" ).stop( true ); }); $( "div#containSlidebanner" ).hover( function (){ }, function (){ $( "ul#slideBanner li" ).animate({ width: "100px" },200); }); }); </script> |