ホームページ  >  記事  >  ウェブフロントエンド  >  Web ページにマウス効果を実装する方法 (詳細なチュートリアル)

Web ページにマウス効果を実装する方法 (詳細なチュートリアル)

亚连
亚连オリジナル
2018-06-12 17:35:464717ブラウズ

読者向けに 10 個の古典的な Web マウスエフェクトコードをまとめて説明しました。必要な友達はそれらを保存できます。

1 4、マウス プロンプトテキストをスクロールした後

<!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: &#39;宋体&#39;,Tahoma ,arial,verdana,sans-serif,&#39;Lucida Grande&#39;,&#39;Lucida Sans Unicode&#39;;
}
*{ margin:0; padding:0;}
h2,h2 a:link,h2 a:hover,h2 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>
<p class="kw_from">
<form action="/search.html" method="get" name="searchForm" id="searchForm" onsubmit="return check()">
<ul id="searchNav">
<li id="conter1"><h2>找什么</h2>
<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"><h2>在那里</h2>
<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>
<p class="sbtn">
<input name="submit" type="submit" class="btn4" style="margin:0px 15px 2px 0;" value="搜索工作" />
</p>
<p class="searchMore">
<a href="search_expert.html" rel="external nofollow" >高级搜索</a><br /><a href="search_sort.html" rel="external nofollow" >分类搜索</a>   </p>
</form>
</p>
</body>
</html>
5. マウスの周りを回転する3枚の羽根の宇宙プロペラ

<html>
<head>
<title>网页特效---跟随鼠标的流星</title>
<meta content="text/html; charset=gb2312" http-equiv="Content-Type">
</head>
<body bgColor="#000000">
<script language="JavaScript">
<!--
Clrs=new Array(&#39;ff0000&#39;,&#39;00ff00&#39;,&#39;ffffff&#39;,&#39;ff00ff&#39;,&#39;ffa500&#39;,&#39;ffff00&#39;,&#39;00ff00&#39;,&#39;ffffff&#39;,&#39;ff00ff&#39;)
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(&#39;<layer name="a0" left=10 top=10 bgcolor="#ff0000" clip="0,0,2,2"></layer>&#39;
+&#39;<layer name="a1" left=10 top=10 bgcolor="#00ff00" clip="0,0,2,2"></layer>&#39;
+&#39;<layer name="a2" left=10 top=10 bgcolor="#ffffff" clip="0,0,2,2"></layer>&#39;
+&#39;<layer name="a3" left=10 top=10 bgcolor="#ffa500" clip="0,0,2,2"></layer>&#39;
+&#39;<layer name="a4" left=10 top=10 bgcolor="#ff00ff" clip="0,0,2,2"></layer>&#39;
+&#39;<layer name="a5" left=10 top=10 bgcolor="#8888ff" clip="0,0,2,2"></layer>&#39;
+&#39;<layer name="a6" left=10 top=10 bgcolor="#fff000" clip="0,0,2,2"></layer>&#39;);
}
else if (document.all){
function FollowMouse(){
Xpos = document.body.scrollLeft+event.x;
Ypos = document.body.scrollTop+event.y;
}
document.onmousemove = FollowMouse;
document.write(&#39;<p id="iep" style="position:absolute;top:0px;left:0px">&#39;
+&#39;<p id="c" style="position:relative">&#39;
+&#39;<p style="position:absolute;top:0px;left:0px;width:2px;height:2px;background:#ff0000;font-size:2px"></p>&#39;
+&#39;<p style="position:absolute;top:0px;left:0px;width:2px;height:2px;background:#00ff00;font-size:2px"></p>&#39;
+&#39;<p style="position:absolute;top:0px;left:0px;width:2px;height:2px;background:#ffffff;font-size:2px"></p>&#39;
+&#39;<p style="position:absolute;top:0px;left:0px;width:2px;height:2px;background:#ffa500;font-size:2px"></p>&#39;
+&#39;<p style="position:absolute;top:0px;left:0px;width:2px;height:2px;background:#ff00ff;font-size:2px"></p>&#39;
+&#39;<p style="position:absolute;top:0px;left:0px;width:2px;height:2px;background:#8888ff;font-size:2px"></p>&#39;
+&#39;<p style="position:absolute;top:0px;left:0px;width:2px;height:2px;background:#fff000;font-size:2px"></p>&#39;
+&#39;</p>&#39;
+&#39;</p>&#39;);
}
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(&#39;sv2()&#39;,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<iep.all.c.all.length;i++)
{
var randCol=Math.round(Math.random()*8);
iep.all.c.all[0].style.background=Clrs[randCol];
iep.all.c.all[0].style.top=Ypos+cntr*Math.cos((RunTime+i*4.5)/5);
iep.all.c.all[0].style.left=Xpos+cntr*Math.sin((RunTime+i*4.5)/5);
}
cntr+=1;
RunTime+=speed;
window.status=RunTime;
stp=setTimeout(&#39;sv2()&#39;,10);
if (cntr>=100)
{
cntr=100;
speed=2.5;
for (i=0;i<iep.all.c.all.length;i++)
{
iep.all.c.all[i].style.top=Ypos+cntr*Math.cos((RunTime-100)*i/90);
iep.all.c.all[i].style.left=Xpos+cntr*Math.sin((RunTime-100)*i/90);
}
}
if (RunTime>182)
{
speed=0.5;
for (i=0;i<iep.all.c.all.length;i++)
{
iep.all.c.all[i].style.top=Ypos+xcntr*Math.cos(((RunTime-182)+i*4.5)/5)*Math.cos((RunTime-182)/5);
iep.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>
6。マウス

<html>
<head>
<title>网页特效--很酷的跟随鼠标的三色彩带</title>
</head><body bgColor=#000000>
<!--将以下代码加入HTML的<Body></Body>之间-->
<script language="JavaScript">
<!--
var a_Colour=&#39;fff000&#39;;
var b_Colour=&#39;00ff00&#39;;
var c_Colour=&#39;ff00ff&#39;;
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(&#39;swirl()&#39;,10);
}
var amount=10;
if (document.layers){
for (i = 0; i < amount; i++)
{
document.write(&#39;<layer name=nsa&#39;+i+&#39; top=0 left=0 width=&#39;+i/2+&#39; height=&#39;+i/2+&#39; bgcolor=&#39;+a_Colour+&#39;></layer>&#39;);
document.write(&#39;<layer name=nsb&#39;+i+&#39; top=0 left=0 width=&#39;+i/2+&#39; height=&#39;+i/2+&#39; bgcolor=&#39;+b_Colour+&#39;></layer>&#39;);
document.write(&#39;<layer name=nsc&#39;+i+&#39; top=0 left=0 width=&#39;+i/2+&#39; height=&#39;+i/2+&#39; bgcolor=&#39;+c_Colour+&#39;></layer>&#39;);
}
}
else if (document.all){
document.write(&#39;<p id="Op" style="position:absolute;top:0px;left:0px">&#39;
+&#39;<p id="Ip" style="position:relative">&#39;);
for (i = 0; i < amount; i++)
{
document.write(&#39;<p id=x style="position:absolute;top:0px;left:0px;width:&#39;+i/2+&#39;;height:&#39;+i/2+&#39;;background:&#39;+a_Colour+&#39;;font-size:&#39;+i/2+&#39;"></p>&#39;);
document.write(&#39;<p id=y style="position:absolute;top:0px;left:0px;width:&#39;+i/2+&#39;;height:&#39;+i/2+&#39;;background:&#39;+b_Colour+&#39;;font-size:&#39;+i/2+&#39;"></p>&#39;);
document.write(&#39;<p id=z style="position:absolute;top:0px;left:0px;width:&#39;+i/2+&#39;;height:&#39;+i/2+&#39;;background:&#39;+c_Colour+&#39;;font-size:&#39;+i/2+&#39;"></p>&#39;);
}
document.write(&#39;</p></p>&#39;);
}
function prepos(){
var ntscp=document.layers;
var msie=document.all;
if (document.layers){
for (i = 0; i < amount; i++)
{
if (i < amount-1)
{
ntscp[&#39;nsa&#39;+i].top=ntscp[&#39;nsa&#39;+(i+1)].top;ntscp[&#39;nsa&#39;+i].left=ntscp[&#39;nsa&#39;+(i+1)].left;
ntscp[&#39;nsb&#39;+i].top=ntscp[&#39;nsb&#39;+(i+1)].top;ntscp[&#39;nsb&#39;+i].left=ntscp[&#39;nsb&#39;+(i+1)].left;
ntscp[&#39;nsc&#39;+i].top=ntscp[&#39;nsc&#39;+(i+1)].top;ntscp[&#39;nsc&#39;+i].left=ntscp[&#39;nsc&#39;+(i+1)].left;
}
else
{
ntscp[&#39;nsa&#39;+i].top=YDummy[0];ntscp[&#39;nsa&#39;+i].left=XDummy[0];
ntscp[&#39;nsb&#39;+i].top=YDummy[1];ntscp[&#39;nsb&#39;+i].left=XDummy[1];
ntscp[&#39;nsc&#39;+i].top=YDummy[2];ntscp[&#39;nsc&#39;+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>
7. マウスの周りに回転する立体的な文字

8. マウスに追従する日付と時刻のダイヤル

<a href="http://www.网址.com" rel="external nofollow" _fcksavedurl="http://www.网址.com" target="_blank" onMouseOver="helpor_net_show(this,event,&#39;网页鼠标特效&#39;)" onMouseOut="helpor_net_hide()">把鼠标放上来试试</a>
<p id="tooltip2" style="position:absolute;visibility:hidden;clip:rect(0 150 50 0);width:150px;background-color:seashell">
<layer name="nstip" width="1000px" bgColor="seashell"></layer>
</p>
<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=&#39;<marquee style="border:1px solid #3399ff">&#39;+text+&#39;</marquee>&#39;
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(&#39;<b>&#39;+text+&#39;</b>&#39;)
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>

9. 非常に特徴的な蛍光マウス

<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(&#39;ff0000&#39;,&#39;00ff00&#39;,&#39;3366ff&#39;,&#39;ff00ff&#39;,&#39;ffa500&#39;,&#39;ffffff&#39;,&#39;fff000&#39;)
//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(&#39;<LAYER NAME="nsstars&#39;+i+&#39;" BGCOLOR=&#39;+colours[i]+&#39; CLIP="0,0,2,2"></LAYER>&#39;);
}
else{
document.write(&#39;<p id="ie" style="position:absolute;top:0;left:0;"><p style="position:relative">&#39;);
for (i=0; i < amount; i++)
document.write(&#39;<span id="iestars" style="position:absolute;top:0;left:0;width:2px;height:2px;background:&#39;+colours[i]+&#39;;font-size:2px"></span>&#39;);
document.write(&#39;</p></p>&#39;);
}
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(&#39;delay()&#39;,10);
}
delay();
//-->
</script>
<script language="JavaScript">
<!-- hide
function goHist(a)
{
history.go(a);
}
//-->
</script>
</body>
</html>

10. マウスを追いかける幻のテキスト

<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(&#39;ff0000&#39;,&#39;00ff00&#39;,&#39;ffffff&#39;,&#39;ff00ff&#39;,&#39;ffa500&#39;,&#39;ffff00&#39;,&#39;00ff00&#39;,&#39;ffffff&#39;,&#39;ff00ff&#39;)
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(&#39;<LAYER NAME="n&#39;+i+&#39;" LEFT=0 TOP=0 BGCOLOR=#FFFFFF CLIP="0,0,2,2"></LAYER>&#39;);
window.captureEvents(Event.MOUSEMOVE);
function nMouse(evnt){
Ypos = evnt.pageY;
Xpos = evnt.pageX;
}
window.onMouseMove=nMouse;
}
else{
document.write(&#39;<p style="position:absolute;top:0px;left:0px">&#39;);
document.write(&#39;<p style="position:relative">&#39;);
for (i=0; i < amount; i++)
document.write(&#39;<p id="me" style="position:absolute;top:0px;left:0px;width:2px;height:2px;font-size:2px;background:#00aaff"></p>&#39;);
document.write(&#39;</p></p>&#39;);
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[&#39;n&#39;+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>

以上、皆さんの参考になれば幸いです。 関連記事:

React で Native を使用して画像表示コンポーネントを実装する

vue-cli と Element-ui を組み合わせて使用​​し、cropper.js に基づいて vue をカプセル化し、画像トリミング コンポーネント機能を実装する

vueでは画像のローカルプレビュー、トリミング、圧縮、アップロードなどの一連の機能をjsで実装します

以上がWeb ページにマウス効果を実装する方法 (詳細なチュートリアル)の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。