成人精品一区二区三区中文字幕-成人精品一区二区三区-成人精品一级毛片-成人精品亚洲-日本在线视频一区二区-日本在线视频免费

導航首頁 ? 技術教程 ? 完美JQuery圖片切換效果的簡單實現
全站頭部文字 我要出現在這里
完美JQuery圖片切換效果的簡單實現 694 2024-02-24   

效果如下:

查看圖片

css:

body { font-family:"Microsoft Yahei"; }
body,ul,li,img,h3,dl,dd,dt,h1{margin:0px;padding:0px;list-style:none;}  
img{vertical-align: top;}
/***大圖切換***/
.scroll_view{margin: 0px auto;overflow:hidden;position: relative;}
.photo_view li{position:absolute;width: 100%;}
.photo_view li em,.photo_view li h3{position: absolute;bottom: 0px;z-index: 1;height: 35px;line-height: 35px;width: 100%;left: 0px;}
.photo_view li em{z-index: 1;background:rgba(0,0,0,0.5);filter: progid:DXImageTransform.Microsoft.gradient( GradientType = 0,startColorstr = '#50000000',endColorstr = '#50000000');_background:#000;}
.photo_view li h3{z-index: 2;text-indent: 1em;font-weight: normal;}
.photo_view li h3 a{color:#fff;}
.photo_view li h3 a:hover{color:#f60;}
.small_photo{position: absolute;bottom: 40px;right: 10px;cursor: pointer;z-index: 4;}
.small_photo li {float: left;padding-right: 10px;}
.small_photo li img{width: 80px;height: 35px;border: solid 2px #ccc;border-radius: 2px;}
.small_photo li.active img{border: solid 2px #f60;}

html:

< start:大圖切換 -->
<div class="scroll_view">
  <ul class="photo_view">
    <li><img src="http://www.gimoo.net/t/1901/images/ad1.jpg" alt="" class="" /><em></em><h3><a href="javascript:void(0);">圖片效果1</a></h3></li>
    <li><img src="http://www.gimoo.net/t/1901/images/ad2.jpg" alt="" class="" /><em></em><h3><a href="javascript:void(0);">圖片效果2</a></h3></li>
    <li><img src="http://www.gimoo.net/t/1901/images/ad3.jpg" alt="" class="" /><em></em><h3><a href="javascript:void(0);">圖片效果3</a></h3></li>
    <li><img src="http://www.gimoo.net/t/1901/images/ad4.jpg" alt="" class="" /><em></em><h3><a href="javascript:void(0);">圖片效果4</a></h3></li>
  </ul>
  <ul class="small_photo"></ul>
</div>
< End:大圖切換 -->

js:

$.fn.extend({  
  imgScroll:function(options){    
    var def={phtot_parent:$(".scroll_view"),photo_view:$(".photo_view"),small_photo:$(".small_photo"),speed:800,isauto:true,width:800,height:349},
      opt=$.extend({},def,options),
      $photo_view=opt.photo_view,
      $small_photo=opt.small_photo,
      speed=opt.speed,
      isauto=opt.isauto,
      index=0,
      _length=$photo_view.find("li").length,
      strTime=null;
    opt.phtot_parent.css({width:opt.width,height:opt.height});
    $photo_view.find("li:not(:first)").hide()//.find("img").hide();
    $photo_view.find("li").each(function(i){
      $small_photo.append('<li><img src="http://www.gimoo.net/t/1901/5c4673fa0a0a1.html'+$(this).find("img").attr("src")+'" alt="" class="" /></li>');
    })
    $small_photo.find("li:first").addClass("active");
    //小圖鼠標動作
    $small_photo.find("li").bind("mouseenter",function(){  
      clearInterval(strTime);
      if(index!=$(this).index()){
        index=$(this).index();  
        animate(index)
      }
    }).bind("mouseleave",function(){      
      if(isauto){
        start();  
      }
    });
    //大圖懸停動作
    $photo_view.find("li").bind("mouseenter",function(){  
      clearInterval(strTime);      
    }).bind("mouseleave",function(){      
      if(isauto){
        start();  
      }
    });
    //自動播放
    if(isauto){
      start();  
    }
    //啟動自動播放
    function start(){
      strTime=setInterval(function(){
        index >= _length-1 ? index=0 : index++;
        animate(index);
      },speed);
    }
    //動畫效果
    function animate(_index){//console.log(_index)
      $small_photo.find("li").eq(_index).addClass('active').siblings().removeClass("active");//改變小圖導航樣式
      $photo_view.find("li").eq(_index).css("z-index",1).siblings().css("z-index",0);//控制absolute的層級
      $photo_view.find("li").eq(_index).show().find("img").css({"opacity": 0});  //裝大圖的opacity設置為0  
      $photo_view.find("li").eq(_index).find("img").animate({opacity:1},300,function(){
        $(this).removeAttr("style");//動畫之后刪除opacity
        $photo_view.find("li").eq(_index).show().siblings().hide();//顯示大圖  
      });//展示當前顯示動畫
    }
  }
});
<script type="text/javascript">
  $(function(){$("scroll_view").imgScroll({photo_view:$(".photo_view"),small_photo:$(".small_photo"),speed:3000,isauto:true}); 
  })
</script>

以上這篇完美JQuery圖片切換效果的簡單實現就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持綠夏網。



主站蜘蛛池模板: 西野翔三级全部电影| 自拍成人| 白上之黑电影| 甲铁城的卡巴内利| 都市频道节目表| 电影《大突围》免费观看国语| 职业目标评估| 拷打| 欠条怎么写才具有法律作用| junk boy| tvb翡翠台直播| 荒笛子简谱| 王李丹妮三级电影| 青草国产在线视频| 湖南卫视直播| 立定心志歌词歌谱| 超在线视频| 郭云飞| 我们的快乐人生 电视剧| 改变自己吉他谱| 拔萝卜短剧| 被侵犯| 大奉打更人电视剧| 暴走财神4| 结婚请帖怎么写| 康斯但丁| 思想道德与法治2023版| 汤唯和梁朝伟拍戏原版| 知否知否应是绿肥红瘦电视剧免费| 庆余年2豆瓣| 母鸡评课| 多少周开始做胎心监护| 唐街十三妹| 二年级写玩具的作文| 风间由美风间ゆみav| 小班安全开学第一课| 九州电影网| 三浦亚沙妃| 爱很简单简谱| 合肥一中最后一卷| 湖南卫视直播|

!!!站長長期在線接!!!

網站、小程序:定制開發/二次開發/仿制開發等

各種疑難雜癥解決/定制接口/定制采集等

站長微信:lxwl520520

站長QQ:1737366103