zoukankan      html  css  js  c++  java
  • 仿china.nba.com焦点图效果(ie6,ff)

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <HEAD>
    <TITLE>New Document</TITLE>
    <style type="text/css">
    #fours_m{z-index:-10; 430px; height:382px; background:#053783 url(http://www.kuanghong.com/han/images/fours_bj.gif) repeat-x 0 bottom;}
    #f_img_roll{float:left;350px; height:300px; position:relative}
    #f_img_roll img{position:absolute; left:0; top:0}
    #f_img_s{float:right; position:relative; 80px; height:300px;}
    #f_img_s ul{margin:0; padding:0; margin-left:6px; list-style:none;}
    #f_img_s li{60px; height:45px;border:1px solid #0066cc;margin-top:3px;}
        #f_img_s img{54px; height:39px; border:3px solid #000066;vertical-align:top; }
    #f_img_s div{top:3px}
    #f_mask{position:absolute; top:3px; right:12px; 75px; height:47px; background:url(http://www.kuanghong.com/han/images/mask.gif) no-repeat;}
    #f_title{font-size:16px; font-weight:bold; clear:both; margin-top:10px; text-align:center; color:#fff; height:70px; 80%}

      </style>
      <script type="text/javascript">
     //图片资源
     var imgs_m=[],imgs_s=[],imgs_title=[];
    imgs_m[0]="http://www.kuanghong.com/han/images/img_1.jpg";
    imgs_m[1]="http://www.kuanghong.com/han/images/img_2.jpg";
    imgs_m[2]="http://www.kuanghong.com/han/images/img_3.jpg";
    imgs_m[3]="http://www.kuanghong.com/han/images/img_4.jpg";
    imgs_m[4]="http://www.kuanghong.com/han/images/img_5.jpg";
    imgs_m[5]="http://www.kuanghong.com/han/images/img_6.jpg";
    imgs_s[0]="http://www.kuanghong.com/han/images/img_1_0.jpg";
    imgs_s[1]="http://www.kuanghong.com/han/images/img_2_0.jpg";
    imgs_s[2]="http://www.kuanghong.com/han/images/img_3_0.jpg";
    imgs_s[3]="http://www.kuanghong.com/han/images/img_4_0.jpg";
    imgs_s[4]="http://www.kuanghong.com/han/images/img_5_0.jpg";
    imgs_s[5]="http://www.kuanghong.com/han/images/img_6_0.jpg";

    imgs_title[0]="第一张";
    imgs_title[1]="第二张";
    imgs_title[2]="第三张";
    imgs_title[3]="第四张";
    imgs_title[4]="第五张";
    imgs_title[5]="第六张";
    //显示小图
    function imgs_s_dis(){
    var imgs=document.getElementById("imgs");
    var fr=document.createDocumentFragment();
    for(var i=0;i<imgs_s.length;i++){
    var li=document.createElement("li");
    li.innerHTML="<img src='"+imgs_s[i]+"' alt='' />";
    lis.push(li);
    fr.appendChild(li);
    }
    imgs.appendChild(fr);
    }

    //图片切换
    function img_scroll(num){
    cur_img.src=imgs_m[num];
    img_title.innerHTML=imgs_title[num];
    }

    //图片切换效果
     var ie=/MSIE/.test(navigator.userAgent);//浏览器
     var img_title=null;//title
     var f_img_roll=null;//大图
     var cur_img=null;//当前大图
     var mb_img=null;//目标图
     var f_mask=null;//MASK层
     var lis=[];//所有LI
     var cur_li=null;//当前MASK所在LI
     var mb_li=null;//目标LI位置
     var tt=null;//时间函数
     var m=0;//默认top
     var r=0;//当前lis下标
     
     //自动播放
     function img_play(){
    r++;
    if(r>lis.length-1)r=0;
    mb_li=lis[r].offsetTop;
    tt=setInterval("f_mask_mov()",25);
    cur_li=lis[r];
    img_scroll(r);

     }

     //加载动作
     function _focus(){
    imgs_s_dis();//初始小图显示
    cur_li=lis[0];//初始当前mask所在元素
    f_img_roll=document.getElementById("f_img_roll");
    cur_img=f_img_roll.getElementsByTagName("img")[0];//得到默认大图引用
    img_title=document.getElementById("f_title");
    f_mask=document.getElementById("f_mask");//得到MASK引用
    for(var i=0;i<lis.length;i++){
    lis[i].onmouseover=function(){
    this.style.border="1px solid #cc0000";
    }
    lis[i].onmouseout=function(){
    this.style.border="1px solid #0066cc";
    }
    lis[i].num=i;
    lis[i].onclick=function(){
    if(cur_li!=this){
    clearTimeout(ttt);//停止自动播放
    r=this.num;
    mb_li=this.offsetTop;
    tt=setInterval("f_mask_mov()",25);
    cur_li=this;
    img_scroll(this.num);
    }
    }
    }
    ttt=setTimeout("img_play()",3000);//开始自动播放
     }
     
     //滑动效果
     function f_mask_mov(){
    if(m>mb_li){
    m-=(m-mb_li)*0.2;
    if((m-1)<mb_li){
    clearTimeout(tt);
    f_mask.style.top=mb_li+"px";
    f_mask_top=mb_li;//更新M值
    m=mb_li;
    ttt=setTimeout("img_play()",3000);//开始自动播放
    return;
    }else{
    f_mask.style.top=m+"px";
    }
    }else{
    m+=(mb_li+5-m)*0.2;
    if(m>mb_li){
    clearTimeout(tt);
    f_mask.style.top=mb_li+"px";
    m=f_mask_top=f_mask.offsetTop;//更新M值
    ttt=setTimeout("img_play()",3000);//开始自动播放
    return;
    }else{
    f_mask.style.top=m+"px";
    }
    }

     }
     window.onload=_focus;
      </script>
    </HEAD>
    <BODY>
    <div id="fours_m">
      <div id="f_img_roll"><img src="http://www.kuanghong.com/han/images/img_1.jpg" /></div>
      <div id="f_img_s">
        <div id="f_mask"></div>
        <ul id="imgs"></ul>
      </div>
      <div id="f_title">第一张</div>
    </div>
    </BODY>
    </HTML>
  • 相关阅读:
    sklearn linear_model,svm,tree,naive bayes,ensemble
    便利过滤
    js下载
    小程序修改radio的大小
    el-tree 问题与需求
    jsp页面用html引入vue.js注意问题
    WebPack
    yarn
    vue-cli 4以上 vue.config.js
    Cannot find module 'core-js/modules/es6.regexp.constructor'
  • 原文地址:https://www.cnblogs.com/zerogo/p/2209259.html
Copyright © 2011-2022 走看看