鼠标跟随的文字变动效果

  作者:bea

保存为.html文件即可运行: <!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-Ty
保存为.html文件即可运行:



<!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=gb2312" />
<title>鼠标跟随</title>
<script language="javascript">
var sum;
function change(){
sum=document.getElementById("test").scrollLeft;
document.getElementById("test").scrollLeft+=40;
if(sum==document.getElementById("test").scrollLeft){document.getElementById("test").scrollLeft=0;}
}
function move(){
document.getElementById("test").style.left=document.body.scrollLeft+window.event.clientX;
document.getElementById("test").style.top=document.body.scrollTop+window.event.clientY;
}
document.onmousemove=move;
</script>

<style type="text/css">
<!--
#test {
height: 40px;
width: 40px;
font-size: 40px;
overflow: hidden;
left: 255px;
top: 89px;
position: absolute;
}
#test #word {
margin: 0px;
height: 40px;
width: 160px;
}
-->
</style>
</head>

<body onload="setInterval('change()',1000)" >
<div id="test" ><div id="word"></div></div>
</body>
</html>




[Ctrl+A 全选 注:
如需引入外部Js需刷新才能执行]



有用  |  无用

猜你喜欢