슬라이딩 캡션 .slide_bg{border:#999999 3px solid;width:207px;height:106px;position:relative;overflow:hidden;float:left;margin-right:16px;margin-top:26px;} .slide_img{background-image:url(/jscss/demoimg/wall1.jpg);width:207px;height:106px;} .slide_txt{width:197px;height:100px;background-color:#000000;position:absolute;top:106px;left:0px;color:#FFCC33;line-height:22px;padding:5px;font-size:12px;} 봄: 봄은 파종의 계절입니다. 여름: 여름은 더운 계절입니다. 가을: 가을은 수확의 계절입니다. 겨울: 겨울은 충격적인 계절입니다. [Ctrl A 모두 선택 참고: 외부 J를 도입해야 하는 경우 실행하려면 새로 고쳐야 합니다. ] var slide_content=function(){ var id="slide_content" //滑动图片父容器的id名 var interval=10; //滑动速度 var interval2=100; //文字滑出延迟时间(毫秒) var interval3=500; //文字内容自动消失的延迟时间(毫秒) var opacity=69; //文字内容图层透明度 var timer2=new Array(); var elem=new Array(); var status=new Array(); var div=document.getElementById(id).getElementsByTagName("div"); var timer3=0; //run_animation var d=function(){ var timer,obj,txt;var ypos=100; this.run=function(pra1,pra2,dir){obj=pra1;txt=pra2;if(dir>0){clearTimeout(timer);clearTimeout(timer3);timer3=setTimeout(obj.up,interval2);}else{clearTimeout(timer);obj.down()};txt.style.filter="alpha(opacity="+opacity+")";txt.style.opacity=opacity/100;} //向上滑动 this.up=function(){if(ypos<=0){txt.style.top="0px"}else{ypos-=10;txt.style.top=ypos+"px";timer=setTimeout(obj.up,interval)}} //向下滑动 this.down=function(){if(ypos>=106){txt.style.top="106px";}else{ypos+=15;txt.style.top=ypos+"px";timer=setTimeout(obj.down,interval)}} } //init mouse_behavior for(var i=0;i<div.length;i+=3){ div[i+1].index=div[i+2].index=i+2; elem[i+2]=new d(); div[i+1].onmouseover=function(){elem[this.index].run(elem[this.index],div[this.index],1)}; div[i+1].onmouseout=function(){var n=this.index;if(status[n]!=1){timer2[n]=setTimeout(imgout,interval3)};function imgout(){elem[n].run(elem[n],div[n],-1)}} div[i+2].onmouseout=function(){elem[this.index].run(elem[this.index],div[this.index],-1);status[this.index]=0} div[i+2].onmouseover=function(){clearTimeout(timer2[this.index]);status[this.index]=1} } } //网页加载完毕时,启动函数 window.onload=slide_content;