您好,登錄后才能下訂單哦!
這篇文章給大家分享的是有關web開發中如何實現經典的網頁鼠標特效的內容。小編覺得挺實用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。
1、鼠標指向出現實用特殊提示
<!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="zh-CN" /> <title>css打造鼠標觸發效果</title> <style type="text/css"> <!-- body { margin: 0; padding: 0; color: #000; font-size: 12px; line-height: 160%; text-align: left; height: 100%; font-family: '宋體',Tahoma ,arial,verdana,sans-serif,'Lucida Grande','Lucida Sans Unicode'; } *{ margin:0; padding:0;} h3,h3 a:link,h3 a:hover,h3 a:visited{ font-size: 14px; text-decoration: none; color: #000000; } .kw_from { padding:20px 0 0 0px; margin: auto; height: 300px; overflow: hidden; width: 650px; } .kw_from .sbtn{ float:left; width:80px; padding: 16px 0 0 0; } .kw_from .searchMore{ float:left; width:80px; padding: 4px; } #searchNav { width:430px; float: left; } #searchNav #conter1, #searchNav #conter3{ float:left; width:250px; } #searchNav #conter2, #searchNav #conter4{ float:left; width:180px; } #searchNav ul { padding: 0; margin: 0; list-style: none; } #searchNav li { float: left; } #searchNav li ul { display: none; top: 20px; } #searchNav li:hover ul, #searchNav li.over ul { display: block; float:left; } #searchNav ul li a{ float:left; display:block; font-size:12px; padding:3px; text-decoration: none; color: #777; } #searchNav ul li a:hover{ background-color:#f4f4f4; } #searchNav #jobKw{ width:220px; height:18px; } #searchNav #cityKw{ width:130px; height:18px; } --> </style> <script type="text/javascript"> <!--//--><![CDATA[//> <!-- startList = function() { if (document.all&&document.getElementById) { navRoot = document.getElementById("searchNav"); for (i=0; i<navRoot.childNodes.length; i++) { node = navRoot.childNodes[i]; if (node.nodeName=="LI") { node.onmouseover=function() { this.className+=" over"; } node.onmouseout=function() { this.className=this.className.replace(" over", ""); } } } } } window.onload=startList; //--><!]]> </script> </head> <body> <div class="kw_from"> <form action="/search.html" method="get" name="searchForm" id="searchForm" onsubmit="return check()"> <ul id="searchNav"> <li id="conter1"><h3>找什么</h3> <input id="jobKw" name="jobKw" type="text" /> <ul id="conter3"> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >會計</a> </li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >網頁設計</a></li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >翻譯</a></li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >家教</a></li> <li><span class="moreCity"><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >更多>> </a></span></li> </ul> </li> <li id="conter2"><h3>在那里</h3> <input id="cityKw" name="cityKw" type="text" /> <ul id="conter4"> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >北京</a> </li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >上海</a></li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >廣州</a></li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >深圳</a></li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >南京</a></li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >天津</a></li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >杭州</a></li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >成都</a></li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >重慶</a></li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >武漢</a></li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >西安</a></li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >沈陽</a></li> <li><span class="moreCity"><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >更多城市>></a></span></li> </ul> </li> </ul> <div class="sbtn"> <input name="submit" type="submit" class="btn4" value="搜索工作" /> </div> <div class="searchMore"> <a href="search_expert.html" rel="external nofollow" >高級搜索</a><br /><a href="search_sort.html" rel="external nofollow" >分類搜索</a> </div> </form> </div> </body> </html>
2、跟隨鼠標的流星
<html> <head> <title>網頁特效---跟隨鼠標的流星</title> <meta content="text/html; charset=gb2312" http-equiv="Content-Type"> </head> <body bgColor="#000000"> <script language="JavaScript"> <!-- Clrs=new Array('ff0000','00ff00','ffffff','ff00ff','ffa500','ffff00','00ff00','ffffff','ff00ff') var speed=1; var RunTime = 0; var cntr=0; var xcntr=100; var Nslayers; var pulse=25; var onClrs; var Xpos = 421; var Ypos = 231; var _y; if (document.layers){ window.captureEvents(Event.MOUSEMOVE); function xFollowMouse(evnt){ Xpos = evnt.pageX; Ypos = evnt.pageY; } window.onMouseMove = xFollowMouse; document.write('<layer name="a0" left=10 top=10 bgcolor="#ff0000" clip="0,0,2,2"></layer>' +'<layer name="a1" left=10 top=10 bgcolor="#00ff00" clip="0,0,2,2"></layer>' +'<layer name="a2" left=10 top=10 bgcolor="#ffffff" clip="0,0,2,2"></layer>' +'<layer name="a3" left=10 top=10 bgcolor="#ffa500" clip="0,0,2,2"></layer>' +'<layer name="a4" left=10 top=10 bgcolor="#ff00ff" clip="0,0,2,2"></layer>' +'<layer name="a5" left=10 top=10 bgcolor="#8888ff" clip="0,0,2,2"></layer>' +'<layer name="a6" left=10 top=10 bgcolor="#fff000" clip="0,0,2,2"></layer>'); } else if (document.all){ function FollowMouse(){ Xpos = document.body.scrollLeft+event.x; Ypos = document.body.scrollTop+event.y; } document.onmousemove = FollowMouse; document.write('<div id="ieDiv" >' +'<div id="c" >' +'<div ></div>' +'<div ></div>' +'<div ></div>' +'<div ></div>' +'<div ></div>' +'<div ></div>' +'<div ></div>' +'</div>' +'</div>'); } function sv2(){ if (document.layers){ for (i=0;i<7;i++) { Nslayers="a"+i; document.layers[0].top=Ypos+cntr*Math.cos((RunTime+i*4.5)/5); document.layers[0].left=Xpos+cntr*Math.sin((RunTime+i*4.5)/5); var randCol=Math.round(Math.random()*8); document.layers[0].bgColor=Clrs[randCol]; } cntr+=1; RunTime+=speed; stp=setTimeout('sv2()',10); if (cntr>=100) { cntr=100; speed=2.5; for (i=0;i<7;i++) { Nslayers="a"+i; document.layers[Nslayers].top=Ypos+cntr*Math.cos((RunTime-100)*i/90); document.layers[Nslayers].left=Xpos+cntr*Math.sin((RunTime-100)*i/90); } } if (RunTime>182) { speed=0.5; for (i=0;i<7;i++) { Nslayers="a"+i; document.layers[Nslayers].top=Ypos+xcntr*Math.cos(((RunTime-182)+i*4.5)/5)*Math.cos((RunTime-182)/5); document.layers[Nslayers].left=Xpos+xcntr*Math.sin(((RunTime-182)+i*4.5)/5); } } } else if (document.all){ for (i=0;i<ieDiv.all.c.all.length;i++) { var randCol=Math.round(Math.random()*8); ieDiv.all.c.all[0].style.background=Clrs[randCol]; ieDiv.all.c.all[0].style.top=Ypos+cntr*Math.cos((RunTime+i*4.5)/5); ieDiv.all.c.all[0].style.left=Xpos+cntr*Math.sin((RunTime+i*4.5)/5); } cntr+=1; RunTime+=speed; window.status=RunTime; stp=setTimeout('sv2()',10); if (cntr>=100) { cntr=100; speed=2.5; for (i=0;i<ieDiv.all.c.all.length;i++) { ieDiv.all.c.all[i].style.top=Ypos+cntr*Math.cos((RunTime-100)*i/90); ieDiv.all.c.all[i].style.left=Xpos+cntr*Math.sin((RunTime-100)*i/90); } } if (RunTime>182) { speed=0.5; for (i=0;i<ieDiv.all.c.all.length;i++) { ieDiv.all.c.all[i].style.top=Ypos+xcntr*Math.cos(((RunTime-182)+i*4.5)/5)*Math.cos((RunTime-182)/5); ieDiv.all.c.all[i].style.left=Xpos+xcntr*Math.sin(((RunTime-182)+i*4.5)/5); } } } if (RunTime>210) { xcntr-=10; } if (document.layers) _y=-window.innerWidth-90; else if (document.all) _y=-document.body.clientWidth-90; if (xcntr <= _y) { RunTime=0; speed=1; cntr=0; xcntr=100; } } sv2() //--> </script> </body> </html>
3、跟隨鼠標的三色彩帶
<html> <head> <title>網頁特效--很酷的跟隨鼠標的三色彩帶</title> </head><body bgColor=#000000> <!--將以下代碼加入HTML的<Body></Body>之間--> <script language="JavaScript"> <!-- var a_Colour='fff000'; var b_Colour='00ff00'; var c_Colour='ff00ff'; var Size=120; var YDummy=new Array(),XDummy=new Array(),xpos=0,ypos=0,ThisStep=0;step=0.6; if (document.layers){ window.captureEvents(Event.MOUSEMOVE); function nsMouse(evnt){ xpos = window.pageYOffset+evnt.pageX+6; ypos = window.pageYOffset+evnt.pageY+16; } window.onMouseMove = nsMouse; } else if (document.all) { function ieMouse(){ xpos = document.body.scrollLeft+event.x+6; ypos = document.body.scrollTop+event.y+16; } document.onmousemove = ieMouse; } function swirl(){ for (i = 0; i < 3; i++) { YDummy[i]=ypos+Size*Math.sin((1*Math.sin((ThisStep)/10))+i*2)*Math.sin((ThisStep)/4); XDummy[i]=xpos+Size*Math.cos((1*Math.sin((ThisStep)/10))+i*2)*Math.sin((ThisStep)/4); } ThisStep+=step; setTimeout('swirl()',10); } var amount=10; if (document.layers){ for (i = 0; i < amount; i++) { document.write('<layer name=nsa'+i+' top=0 left=0 width='+i/2+' height='+i/2+' bgcolor='+a_Colour+'></layer>'); document.write('<layer name=nsb'+i+' top=0 left=0 width='+i/2+' height='+i/2+' bgcolor='+b_Colour+'></layer>'); document.write('<layer name=nsc'+i+' top=0 left=0 width='+i/2+' height='+i/2+' bgcolor='+c_Colour+'></layer>'); } } else if (document.all){ document.write('<div id="ODiv" >' +'<div id="IDiv" >'); for (i = 0; i < amount; i++) { document.write('<div id=x ></div>'); document.write('<div id=y ></div>'); document.write('<div id=z ></div>'); } document.write('</div></div>'); } function prepos(){ var ntscp=document.layers; var msie=document.all; if (document.layers){ for (i = 0; i < amount; i++) { if (i < amount-1) { ntscp['nsa'+i].top=ntscp['nsa'+(i+1)].top;ntscp['nsa'+i].left=ntscp['nsa'+(i+1)].left; ntscp['nsb'+i].top=ntscp['nsb'+(i+1)].top;ntscp['nsb'+i].left=ntscp['nsb'+(i+1)].left; ntscp['nsc'+i].top=ntscp['nsc'+(i+1)].top;ntscp['nsc'+i].left=ntscp['nsc'+(i+1)].left; } else { ntscp['nsa'+i].top=YDummy[0];ntscp['nsa'+i].left=XDummy[0]; ntscp['nsb'+i].top=YDummy[1];ntscp['nsb'+i].left=XDummy[1]; ntscp['nsc'+i].top=YDummy[2];ntscp['nsc'+i].left=XDummy[2]; } } } else if (document.all){ for (i = 0; i < amount; i++) { if (i < amount-1) { msie.x[i].style.top=msie.x[i+1].style.top;msie.x[i].style.left=msie.x[i+1].style.left; msie.y[i].style.top=msie.y[i+1].style.top;msie.y[i].style.left=msie.y[i+1].style.left; msie.z[i].style.top=msie.z[i+1].style.top;msie.z[i].style.left=msie.z[i+1].style.left; } else { msie.x[i].style.top=YDummy[0];msie.x[i].style.left=XDummy[0]; msie.y[i].style.top=YDummy[1];msie.y[i].style.left=XDummy[1]; msie.z[i].style.top=YDummy[2];msie.z[i].style.left=XDummy[2]; } } } setTimeout("prepos()",10); } function Start(){ swirl(),prepos() } window.onload=Start; // --> </script> </body></html>
4、鼠標經過滾動提示文字
<a href="http://www.網址.com" rel="external nofollow" _fcksavedurl="http://www.網址.com" target="_blank" onMouseOver="helpor_net_show(this,event,'網頁鼠標特效')" onMouseOut="helpor_net_hide()">把鼠標放上來試試</a> <div id="tooltip2" > <layer name="nstip" width="1000px" bgColor="seashell"></layer> </div> <SCRIPT language="JavaScript"> <!-- if (!document.layers&&!document.all) event="test" function helpor_net_show(current,e,text){ if (document.all&&document.readyState=="complete"){ document.all.tooltip2.innerHTML='<marquee >'+text+'</marquee>' document.all.tooltip2.style.pixelLeft=event.clientX+document.body.scrollLeft+10 document.all.tooltip2.style.pixelTop=event.clientY+document.body.scrollTop+10 document.all.tooltip2.style.visibility="visible" } else if (document.layers){ document.tooltip2.document.nstip.document.write('<b>'+text+'</b>') document.tooltip2.document.nstip.document.close() document.tooltip2.document.nstip.left=0 currentscroll=setInterval("scrolltip()",100) document.tooltip2.left=e.pageX+10 document.tooltip2.top=e.pageY+10 document.tooltip2.visibility="show" } } function helpor_net_hide(){ if (document.all) document.all.tooltip2.style.visibility="hidden" else if (document.layers){ clearInterval(currentscroll) document.tooltip2.visibility="hidden" } } function scrolltip(){ if (document.tooltip2.document.nstip.left>=-document.tooltip2.document.nstip.document.width) document.tooltip2.document.nstip.left-=5 else document.tooltip2.document.nstip.left=150 } //--> </SCRIPT>
5、圍繞鼠標旋轉的三葉空間旋漿
<html> <head> <title>圍繞鼠標旋轉的三葉空間旋漿</title> <meta content="text/html; charset=gb2312" http-equiv="Content-Type"> </head> <body bgColor="#000000"> <script language="JavaScript"> <!-- //To add more stars simply add more colours in below array!! colours=new Array('ff0000','00ff00','3366ff','ff00ff','ffa500','ffffff','fff000') //Alter nothing below!! amount=colours.length; YgetDelay=0,XgetDelay=0,Ydelay=0,Xdelay=0,ns=(document.layers)?1:0,step=0.2,currStep=0,my=0,mx=0; if (ns){ for (i=0; i < amount; i++) document.write('<LAYER NAME="nsstars'+i+'" BGCOLOR='+colours[i]+' CLIP="0,0,2,2"></LAYER>'); } else{ document.write('<div id="ie" ><div >'); for (i=0; i < amount; i++) document.write('<span id="iestars" ></span>'); document.write('</div></div>'); } if (ns){ window.captureEvents(Event.MOUSEMOVE); function nMouse(evnt){ my=evnt.pageY;mx=evnt.pageX } window.onMouseMove=nMouse; } else{ function iMouse(){ my=event.y;mx=event.x; } document.onmousemove=iMouse } function stars(){ if (!ns)ie.style.top=document.body.scrollTop; for (i=0; i < amount; i++) { var layer=(document.layers)?document.layers["nsstars"+i]:iestars[i].style; layer.top= Ydelay+100*Math.sin((5*Math.sin((currStep-15.99)/10))+i*70)*Math.sin((currStep)/10)*Math.cos((currStep+i*25)/10); layer.left=Xdelay+180*Math.cos((5*Math.sin((currStep-15.99)/10))+i*70)*Math.sin((currStep)/10)*Math.cos((currStep+i*25)/10); } currStep+=step; } function delay(){ Ydelay = YgetDelay+=(my-YgetDelay)*1/20; Xdelay = XgetDelay+=(mx-XgetDelay)*1/20; stars(); setTimeout('delay()',10); } delay(); //--> </script> <script language="JavaScript"> <!-- hide function goHist(a) { history.go(a); } //--> </script> </body> </html>
6、圍繞鼠標的立體星環(摩天輪)
<html> <head> <title>圍繞鼠標的立體星環</title> <meta content="text/html; charset=gb2312" http-equiv="Content-Type"> <script language="JavaScript"> <!-- ns=(document.layers)?1:0; Clrs=new Array('ff0000','00ff00','ffffff','ff00ff','ffa500','ffff00','00ff00','ffffff','ff00ff') var amount=8 var step=0.3; var currStep=0; var Ypos=0; var Xpos=0; if (ns){ for (i=0; i < amount; i++) document.write('<LAYER NAME="n'+i+'" LEFT=0 TOP=0 BGCOLOR=#FFFFFF CLIP="0,0,2,2"></LAYER>'); window.captureEvents(Event.MOUSEMOVE); function nMouse(evnt){ Ypos = evnt.pageY; Xpos = evnt.pageX; } window.onMouseMove=nMouse; } else{ document.write('<div >'); document.write('<div >'); for (i=0; i < amount; i++) document.write('<div id="me" ></div>'); document.write('</div></div>'); function iMouse(){ Ypos=event.y+document.body.scrollTop; Xpos=event.x+document.body.scrollLeft; } document.onmousemove = iMouse; } function Comet(){ for (i=0; i < amount; i++){ var randCol=Math.floor(Math.random()*Clrs.length); var layer=(document.layers)?document.layers['n'+i]:me[i].style; layer.top =Ypos+60*Math.sin((currStep + i*3.1)/4)*Math.cos(currStep/10); layer.left=Xpos+60*Math.cos((currStep + i*3.1)/4); if (ns) layer.bgColor=Clrs[randCol];else layer.background=Clrs[randCol]; } currStep+=step; setTimeout("Comet()",10); } window.onload=Comet; // --> </script> </head> <body bgcolor="#000000"> </body> </html>
7、圍繞鼠標的立體旋轉文字
<html> <head> <title>圍繞鼠標的立體旋轉文字</title> <meta content="text/html; charset=gb2312" http-equiv="Content-Type"> <meta content="Microsoft FrontPage 5.0" name="GENERATOR"> </head> <body> <script LANGUAGE="JavaScript"> <!-- Begin if (document.all) { yourLogo = "網頁制作大寶庫"; //Not less than 2 letters! logoFont = "Arial"; logoColor = "ff0000"; //Nothing needs altering below! yourLogo = yourLogo.split(''); L = yourLogo.length; TrigSplit = 360 / L; Sz = new Array() logoWidth = 100; logoHeight = -30; ypos = 0; xpos = 0; step = 0.09; currStep = 0; document.write('<div id="outer" ><div >'); for (i = 0; i < L; i++) { document.write('<div id="ie" style="position:absolute;top:0px;left:0px;' +'width:10px;height:10px;font-family:'+logoFont+';font-size:12px;' +'color:'+logoColor+';text-align:center">'+yourLogo[i]+'</div>'); } document.write('</div></div>'); function Mouse() { ypos = event.y; xpos = event.x - 5; } document.onmousemove=Mouse; function animateLogo() { outer.style.pixelTop = document.body.scrollTop; for (i = 0; i < L; i++) { ie[i].style.top = ypos + logoHeight * Math.sin(currStep + i * TrigSplit * Math.PI / 180); ie[i].style.left = xpos + logoWidth * Math.cos(currStep + i * TrigSplit * Math.PI / 180); Sz[i] = ie[i].style.pixelTop - ypos; if (Sz[i] < 5) Sz[i] = 5; ie[i].style.fontSize = Sz[i] / 1.7; } currStep -= step; setTimeout('animateLogo()', 20); } window.onload = animateLogo; } // End --> </script> </body> </html>
8、跟隨鼠標的日期時間表盤
<html> <head> <title>跟隨鼠標的日期時間表盤</title> </head><BODY> <!--將以下代碼加入HTML的<Body></Body>之間--> <SCRIPT language=JavaScript> <!-- dCol="0000FF" fCol="FF0000" sCol="00FF00" mCol="000000" hCol="000000" ClockHeight=40; ClockWidth=40; ClockFromMouseY=0; ClockFromMouseX=100; d=new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六"); m=new Array("1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"); date=new Date(); day=date.getDate(); year=date.getYear(); if (year < 2000) year=year+1900; TodaysDate="年 "+m[date.getMonth()]+" "+day+"日 "+d[date.getDay()]+" "+year; D=TodaysDate.split(''); H='...'; H=H.split(''); M='....'; M=M.split(''); S='.....'; S=S.split(''); Face='1 2 3 4 5 6 7 8 9 10 11 12'; font='Arial'; size=1; speed=0.6; ns=(document.layers); ie=(document.all); Face=Face.split(' '); n=Face.length; a=size*10; ymouse=0; xmouse=0; scrll=0; props="<font face="+font+" size="+size+" color="+fCol+">"; props2="<font face="+font+" size="+size+" color="+dCol+">"; Split=360/n; Dsplit=360/D.length; HandHeight=ClockHeight/4.5 HandWidth=ClockWidth/4.5 HandY=-7; HandX=-2.5; scrll=0; step=0.06; currStep=0; y=new Array();x=new Array();Y=new Array();X=new Array(); for (i=0; i < n; i++){y[i]=0;x[i]=0;Y[i]=0;X[i]=0} Dy=new Array();Dx=new Array();DY=new Array();DX=new Array(); for (i=0; i < D.length; i++){Dy[i]=0;Dx[i]=0;DY[i]=0;DX[i]=0} if (ns){ for (i=0; i < D.length; i++) document.write('<layer name="nsDate'+i+'" top=0 left=0 height='+a+' width='+a+'><center>'+props2+D[i]+'</font></center></layer>'); for (i=0; i < n; i++) document.write('<layer name="nsFace'+i+'" top=0 left=0 height='+a+' width='+a+'><center>'+props+Face[i]+'</font></center></layer>'); for (i=0; i < S.length; i++) document.write('<layer name=nsSeconds'+i+' top=0 left=0 width=15 height=15><font face=Arial size=3 color='+sCol+'><center><b>'+S[i]+'</b></center></font></layer>'); for (i=0; i < M.length; i++) document.write('<layer name=nsMinutes'+i+' top=0 left=0 width=15 height=15><font face=Arial size=3 color='+mCol+'><center><b>'+M[i]+'</b></center></font></layer>'); for (i=0; i < H.length; i++) document.write('<layer name=nsHours'+i+' top=0 left=0 width=15 height=15><font face=Arial size=3 color='+hCol+'><center><b>'+H[i]+'</b></center></font></layer>'); } if (ie){ document.write('<div id="Od" ><div >'); for (i=0; i < D.length; i++) document.write('<div id="ieDate" >'+props2+D[i]+'</font></div>'); document.write('</div></div>'); document.write('<div id="Of" ><div >'); for (i=0; i < n; i++) document.write('<div id="ieFace" >'+props+Face[i]+'</font></div>'); document.write('</div></div>'); document.write('<div id="Oh" ><div >'); for (i=0; i < H.length; i++) document.write('<div id="ieHours" >'+H[i]+'</div>'); document.write('</div></div>'); document.write('<div id="Om" ><div >'); for (i=0; i < M.length; i++) document.write('<div id="ieMinutes" >'+M[i]+'</div>'); document.write('</div></div>') document.write('<div id="Os" ><div >'); for (i=0; i < S.length; i++) document.write('<div id="ieSeconds" >'+S[i]+'</div>'); document.write('</div></div>') } (ns)?window.captureEvents(Event.MOUSEMOVE):0; function Mouse(evnt){ ymouse = (ns)?evnt.pageY+ClockFromMouseY-(window.pageYOffset):event.y+ClockFromMouseY; xmouse = (ns)?evnt.pageX+ClockFromMouseX:event.x+ClockFromMouseX; } (ns)?window.onMouseMove=Mouse:document.onmousemove=Mouse; function ClockAndAssign(){ time = new Date (); secs = time.getSeconds(); sec = -1.57 + Math.PI * secs/30; mins = time.getMinutes(); min = -1.57 + Math.PI * mins/30; hr = time.getHours(); hrs = -1.575 + Math.PI * hr/6+Math.PI*parseInt(time.getMinutes())/360; if (ie){ Od.style.top=window.document.body.scrollTop; Of.style.top=window.document.body.scrollTop; Oh.style.top=window.document.body.scrollTop; Om.style.top=window.document.body.scrollTop; Os.style.top=window.document.body.scrollTop; } for (i=0; i < n; i++){ var F=(ns)?document.layers['nsFace'+i]:ieFace[i].style; F.top=y[i] + ClockHeight*Math.sin(-1.0471 + i*Split*Math.PI/180)+scrll; F.left=x[i] + ClockWidth*Math.cos(-1.0471 + i*Split*Math.PI/180); } for (i=0; i < H.length; i++){ var HL=(ns)?document.layers['nsHours'+i]:ieHours[i].style; HL.top=y[i]+HandY+(i*HandHeight)*Math.sin(hrs)+scrll; HL.left=x[i]+HandX+(i*HandWidth)*Math.cos(hrs); } for (i=0; i < M.length; i++){ var ML=(ns)?document.layers['nsMinutes'+i]:ieMinutes[i].style; ML.top=y[i]+HandY+(i*HandHeight)*Math.sin(min)+scrll; ML.left=x[i]+HandX+(i*HandWidth)*Math.cos(min); } for (i=0; i < S.length; i++){ var SL=(ns)?document.layers['nsSeconds'+i]:ieSeconds[i].style; SL.top=y[i]+HandY+(i*HandHeight)*Math.sin(sec)+scrll; SL.left=x[i]+HandX+(i*HandWidth)*Math.cos(sec); } for (i=0; i < D.length; i++){ var DL=(ns)?document.layers['nsDate'+i]:ieDate[i].style; DL.top=Dy[i] + ClockHeight*1.5*Math.sin(currStep+i*Dsplit*Math.PI/180)+scrll; DL.left=Dx[i] + ClockWidth*1.5*Math.cos(currStep+i*Dsplit*Math.PI/180); } currStep-=step; } function Delay(){ scrll=(ns)?window.pageYOffset:0; Dy[0]=Math.round(DY[0]+=((ymouse)-DY[0])*speed); Dx[0]=Math.round(DX[0]+=((xmouse)-DX[0])*speed); for (i=1; i < D.length; i++){ Dy[i]=Math.round(DY[i]+=(Dy[i-1]-DY[i])*speed); Dx[i]=Math.round(DX[i]+=(Dx[i-1]-DX[i])*speed); } y[0]=Math.round(Y[0]+=((ymouse)-Y[0])*speed); x[0]=Math.round(X[0]+=((xmouse)-X[0])*speed); for (i=1; i < n; i++){ y[i]=Math.round(Y[i]+=(y[i-1]-Y[i])*speed); x[i]=Math.round(X[i]+=(x[i-1]-X[i])*speed); } ClockAndAssign(); setTimeout('Delay()',40); } if (ns||ie)window.onload=Delay; //--> </SCRIPT> </body></html>
9、很有特色的熒光鼠標
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>很有特色的熒光鼠標</title> <meta name="GENERATOR" content="Microsoft FrontPage 5.0"> </head> <body id="mybody" bgcolor="#ffffff" text="#000000"> <div id="Layer1" > <dd> <div align="right"> <img src="images/light.gif" width="29" height="30"> </div> </dd> </div> <p align="center"><b><font size="5">日落大道上的亞洲男孩 </font></b> </p> <table border="0" width="100%"> <tr> <td width="82%"><font face="宋體" color="#FF00FF" > </font><span > 人人愛談張愛玲,尤其在論及服飾的時候。我不能免俗,也來附庸風雅一番。張愛玲紀念文集提到她逝世時的寓所,地址非常眼熟,后來才知道那公寓就在UC LA正門附近。我和朋友好奇心起,課后前去朝圣一番,發現果真就是文集照片中的公寓,只不過屋前綠樹茁壯更勝以往,和目前公寓的灰暗色調形成諷刺對比。耳聞張愛玲生前喜歡在UCLA附近不時搬遷,居無定所,像一頭中槍后逃逸的狐貍,不停回頭將沿路滴落的血跡舐去,以免獵人循跡跟上。 <br> <br> 我以剛出道的獵人口吻說∶傳言中張的住所很狼狽,她的衣物都隨便擱在紙箱或超級市場收集來的塑膠袋里唷。 <br> <br> 比我早來洛杉磯數年的同行朋友卻說∶有何奇怪?我的衣物書籍也都塞在紙箱和塑膠袋里。搬家的時候反而方便啊。 <br> <br> 朋友的粗廉生活讓我很不以為然;當時我才初抵美國未久。 <br> <br> 試想,任何華麗的衣裳只要一落進超級市場塑膠袋,看起來就像垃圾。把生活盡數裝在塑膠袋里,豈不是將自己完全垃圾化? <br> <br> 但,在開始租屋、收集家具之后,我也開始世故馴化。留學生余錢無多,時常面臨搬家壓力。因此,我很少購衣;如要花錢,選擇并不多。 <br> <br> 從UCLA門口驅車南行,經過張愛玲故居,就來到了”ROSS“成衣批發店。ROSS陳列滿坑滿谷的名牌服飾,但因都是瑕疵品,比如說胸口的商標掉到肚臍位置的馬球衫之類,張冠李戴,品質荒唐,所以售價低廉。許多經濟能力較差的黑人和墨西哥人就來這里翻索便宜的CK、耐吉、DKNY;我加入他們膚色鮮艷的行列,結帳時將微疵的戰利品裝在塑膠袋里-而非百貨公司的雅痞紙袋。說不定當年張愛玲也曾經蹋著臉徒步到這里找便宜貨,混跡各色人種之間,沒有人認出她何許人也。 <br> <br> 雖然每次光顧ROSS都省了錢,而且享受與有色人種站在同一陣線的政治正確虛榮感,但每一次的經驗都極其卑微沮喪。好萊塢電影中,彩色畫報里,那種昂首闊步走進香蕉共和國的瀟灑意象,在現實美國里卻好遙遠。還是認份光顧量販店,站在平庸空間里排隊,細細咀嚼外國人的貧窮滋味。 <br> <br> 時裝海報里,那些空靈的軀干之間,并沒有留下什么空位給我者。 <br> <br> 在日落大道兩岸,巨幅時裝廣告海報一張張浮懸空中,像敦煌壁畫,海報里俊男美女睥睨眾生,佛似的自在莊嚴,日落大道一如當代加 <br> <br> 州的絲路。AF,Abercrombie & Fitch的白人男孩在陽光下微笑展示金身,好生慈悲。我猜美國當前年輕男性最風靡的服飾品牌之一大概就是AF,青春的傲慢包裝成若無其事的天真瀟灑。難怪校園里穿AF的大男孩比比皆是(怪的是,任何人穿了AF就會變得性感);許多男同志也表示,看了AF男孩就會流口水(許多人在徵友廣告中表明,想要找AF風格的男孩)。記得春天清晨我行過波士頓哈佛大學,赫然發現哈佛廣場前最招搖的海報就來自AF,金發男孩的美麗笑臉占據了整個櫥窗,詭異的意象。光是一張笑臉就比一家書店還要龐大。我望之卻步了。 <br> <br> </span></td> </tr> </table> <script language="vbscript"> dim red,gre,blu dim x,y,z red=255 gre=255 blu=0 z=100 sub window_onload() call mybody.filters.light.addPoint(0,0,z,Red,Gre,Blu,100) mybody.style.cursor="hand" end sub sub document_onmousemove() x=window.event.x y=window.event.y call mybody.filters.Light.MoveLight(0, x, y, 100, 1) end sub </script> <script language="javascript"> //這是使圖層移動的函數 function move_layer() { Layer1.style.left=event.clientX+document.body.scrollLeft-50; Layer1.style.top=event.clientY+document.body.scrollTop-20; } //這里的意思是,如果鼠標移動時就調用"move_layer"函數 document.onmousemove =move_layer; </script> </body> </html>
10、跟隨鼠標的幻影文字
<html> <head> <title>中國站長站--跟隨鼠標的幻影文字</title> </head> <body> <script LANGUAGE="JavaScript"> <!-- Begin message = '歡迎訪問網頁制作大寶庫!'; FonT = 'Verdana'; ColoR = 'ff0000'; SizE = 3; //1 to 7 only! var amount = 5, ypos =- 50, xpos = 0, Ay = 0, Ax = 0, By = 0, Bx = 0, Cy = 0, Cx = 0, Dy = 0, Dx = 0, Ey = 0, Ex = 0; if (document.layers) { for (i = 0; i < amount; i++) { document.write('<layer name=nsl'+i+' top=0 left=0><font face='+FonT+' size='+SizE+' color='+ColoR+'>'+message+'</font></layer>'); } window.captureEvents(Event.MOUSEMOVE); function nsmouse(evnt) { xpos = evnt.pageX + 20; ypos = evnt.pageY + 20; } window.onMouseMove = nsmouse; } else if (document.all) { document.write("<div id='outer' style='position:absolute;top:0px;left:0px'>"); document.write("<div style='position:relative'>"); for (i = 0; i < amount; i++) { document.write('<div id="text"'+i+' ><font face='+FonT+' size='+SizE+' color='+ColoR+'>'+message+'</font></div>') } document.write("</div>"); document.write("</div>"); function iemouse() { ypos = event.y + 20; xpos = event.x + 20; } window.document.onmousemove = iemouse; } function makefollow() { if (document.layers) { document.layers['nsl'+0].top = ay; document.layers['nsl'+0].left = ax; document.layers['nsl'+1].top = by; document.layers['nsl'+1].left = bx; document.layers['nsl'+2].top = cy; document.layers['nsl'+2].left = cx; document.layers['nsl'+3].top = Dy; document.layers['nsl'+3].left = Dx; document.layers['nsl'+4].top = Ey; document.layers['nsl'+4].left = Ex; } else if (document.all) { outer.style.pixelTop = document.body.scrollTop; text[0].style.pixelTop = ay; text[0].style.pixelLeft = ax; text[1].style.pixelTop = by; text[1].style.pixelLeft = bx; text[2].style.pixelTop = cy; text[2].style.pixelLeft = cx; text[3].style.pixelTop = Dy; text[3].style.pixelLeft = Dx; text[4].style.pixelTop = Ey; text[4].style.pixelLeft = Ex; } } function move() { ey = Ey += (ypos - Ey) * 0.2; ex = Ex += (xpos - Ex) * 0.2; dy = Dy += (ey - Dy) * 0.3; dx = Dx += (ex - Dx) * 0.3; cy = Cy += (dy - Cy) * 0.4; cx = Cx += (dx - Cx) * 0.4; by = By += (cy - By) * 0.5; bx = Bx += (cx - Bx) * 0.5; ay = Ay += (by - Ay) * 0.6; ax = Ax += (bx - Ax) * 0.6; makefollow(); setTimeout('move()', 100); } window.onload=move; // End --> </script> </body> </html>
感謝各位的閱讀!關于“web開發中如何實現經典的網頁鼠標特效”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,讓大家可以學到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。