CSS3图片放大缩小切换代码特效
2014-02-16 03:53:31 -0500
与大家分享一款基于纯CSS3代码的图片放大、图片缩小显示特效,带动画效果,测试请使用IE9,火狐或Chrome,CSS3的动画处理能力很强,传统的CSS是无法比拟的。本款动画效果类似Flash,但与Flash不粘边,有兴趣请参阅代码吧。转自笑忘书
<style> .textboxstyle { font-family:Arial; font-size:16pt; color:black; text-align:center; vertical-align:top; } .textboxbackgroundstyle { background-color:white; padding:5px; -moz-border-radius-topleft: 15px; -moz-border-radius-bottomright: 15px; -webkit-border-top-left-radius: 15px; -webkit-border-bottom-right-radius: 15px; border-top-left-radius: 15px; border-bottom-right-radius: 15px; } .curveandshadowstyle { -moz-box-shadow: 5px 5px 8px #818181; -moz-border-radius-topleft: 25px; -moz-border-radius-bottomright: 25px; -webkit-box-shadow: 5px 5px 8px #818181; -webkit-border-top-left-radius: 25px; -webkit-border-bottom-right-radius: 25px; box-shadow: 5px 5px 5px #818181; border-top-left-radius: 25px; border-bottom-right-radius: 25px; filter: progid:DXImageTransform.Microsoft.Shadow(Strength=5, Direction=135, Color='#818181'); border-style:solid; border-width:1px; border-color:white; } </style> <script> var imgurl= new Array() var message= new Array() var thislink= new Array() imgurl[0]="http://csngmap.wodemo.com/down/20140216/257532/%E5%AD%A6%E7%94%9FMM.jpg" imgurl[1]="http://csngmap.wodemo.com/down/20140216/257552/%E6%B8%85%E5%87%89%E5%B0%8F%E5%A6%B9.jpg" message[0]="欢迎光" message[1]="csngmap资源分享大本营" thislink[0]="#" thislink[1]="#" var imgwidth=320 var imgheight=680 var stillstand=2.5 var opacitystrength=60 var tmr var step=10 var i=imgwidth var i_imgurl=0 stillstand*=1000 var preloadedimages=new Array() for (iii=0;iii<imgurl.length;iii++){ preloadedimages[iii]=new Image() preloadedimages[iii].src=imgurl[iii] } function shrinkpic() { document.getElementById("textbox").innerHTML="" if (i>0) { i-=step document.getElementById("picdiv").style.width=i+"px" document.getElementById("picdiv").style.height=i*(imgheight/imgwidth)+"px" document.getElementById("picdiv").style.left=imgwidth/2-(i/2)+"px" document.getElementById("picdiv").style.top=(imgwidth/2-(i/2))*(imgheight/imgwidth)+"px" tmr=setTimeout("shrinkpic()",20) } else { i_imgurl++ if (i_imgurl>=imgurl.length) { i_imgurl=0 } document.getElementById("picdiv").style.background="url("+imgurl[i_imgurl]+")" i=1 tmr=setTimeout("enlargepic()",20) } } function enlargepic() { if (i<=imgwidth) { i+=step document.getElementById("picdiv").style.width=i+"px" document.getElementById("picdiv").style.height=i*(imgheight/imgwidth)+"px" document.getElementById("picdiv").style.left=imgwidth/2-(i/2)+"px" document.getElementById("picdiv").style.top=(imgwidth/2-(i/2))*(imgheight/imgwidth)+"px" tmr=setTimeout("enlargepic()",20) } else { i=imgwidth showmessage() } } function showmessage() { document.getElementById("textbox").innerHTML='<span class="textboxbackgroundstyle">'+message[i_imgurl]+'</span>' tmr=setTimeout("shrinkpic()",stillstand) } function gotothislink(){ document.location.href=thislink[i_imgurl] } document.write('<div id="roof" style="position:relative;width:'+imgwidth+'px;height:'+imgheight+'px;">') document.write('<div id="picdiv" class="curveandshadowstyle" style="position:absolute;background:url('+imgurl[0]+');width:'+imgwidth+'px;height:'+imgheight+'px;top:0px;left:0px;"></div>') document.write('<div id="tt" onClick="gotothislink()" style="position:absolute;width:'+imgwidth+'px;height:'+imgheight+'px;top:0px;left:0px;filter:alpha(opacity='+opacitystrength+');opacity:'+(opacitystrength/100)+';cursor:pointer;"><table width='+imgwidth+' height='+imgheight+'><tr><td id="textbox" class="textboxstyle"><span class="textboxbackgroundstyle">'+message[0]+'</span></td></tr></table></div>') document.write('</div>') window.onload=shrinkpic </script>
«Newer
Older»
Comment:
Name:
Back to home
代码 /cat/111288