Image Rotator & jQuery
Image Rotator & jQuery 是一个带有图片描述说明的图片轮播效果。
Image Rotator 效果使用的代码之少,布局也合理。
当我们把鼠标移到图片列表上时,有选中效果,
当我点击某一个图片列表之时出现了Rotator效果,
并且在图片的底部会有透明的图片描述说明框。
前一段时间我在项目中也用到过此类似的功能,我是用JavaScript简单的实现了一下。没有此例子效果好,用户体验好。
此例子我们可以应用到重点产品推荐和Image Gallery 上
关键代码如下:
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 40 41 42 | $(document).ready(function() { //Show Banner $(".main_image .desc").show(); //Show Banner $(".main_image .block").animate({ opacity: 0.85 }, 1 ); //Set Opacity //Click and Hover events for thumbnail list $(".image_thumb ul li:first").addClass('active'); $(".image_thumb ul li").click(function(){ //Set Variables var imgAlt = $(this).find('img').attr("alt"); //Get Alt Tag of Image var imgTitle = $(this).find('a').attr("href"); //Get Main Image URL var imgDesc = $(this).find('.block').html(); //Get HTML of block var imgDescHeight = $(".main_image").find('.block').height(); //Calculate height of block if ($(this).is(".active")) { //If it's already active, then... return false; // Don't click through } else { //Animate the Teaser $(".main_image .block").animate({ opacity: 0, marginBottom: -imgDescHeight }, 250 , function() { $(".main_image .block").html(imgDesc).animate({ opacity: 0.85, marginBottom: "0" }, 250 ); $(".main_image img").attr({ src: imgTitle , alt: imgAlt}); }); } $(".image_thumb ul li").removeClass('active'); //Remove class of 'active' on all lists $(this).addClass('active'); //add class of 'active' on this list only return false; }) .hover(function(){ $(this).addClass('hover'); }, function() { $(this).removeClass('hover'); }); //Toggle Teaser $("a.collapse").click(function(){ $(".main_image .block").slideToggle(); $("a.collapse").toggleClass("show"); }); });//Close Function |
演示:http://blog.moocss.com/jQuery/demo16/Image-Rotator/index.htm
下载:http://blog.moocss.com/jQuery/demo16/
项目来源于: Soh Tanaka – http://www.sohtanaka.com/
文章评论 已经有 0 条评论!