47.html

来自「javescript网页特效80个例子」· HTML 代码 · 共 52 行

HTML
52
字号
<html>
<head>
<title>不断转动的文字</title>
<SCRIPT language=JavaScript>
<!-- 
if (document.all){

msg=" *** 不断转动 不停的转动";  //设置转动内容
msgColor="red";  //设置文字颜色
msgFont="Arial";  //设置文字字体

msg=msg.split('');
n=msg.length; 
e=360/n;
yp=110;
xp=110;
yb=40;  //设置以隐藏基线为基准的垂直坐标
xb=80; //设置以隐藏基线的宽度
sa=0.06;
sb=100;
pa=new Array();
pb=new Array();
for (i=0; i < n; i++){
document.write('<div id="txtaress" style="position:absolute;top:0;left:0;'
+'height:0;width:0;font-family:'+msgFont+';text-align:center;color:'+msgColor+'">'+msg[i]+'</div>');
}
function ani(){
yp=document.body.scrollTop+100;  //设置圆心的纵坐标
xp=document.body.scrollLeft+window.document.body.clientWidth-400;  //设置圆心的横坐标
for (i=0; i < n; i++){
txtaress[i].style.top =yp+yb*Math.sin(sb+i*e*Math.PI/180);
txtaress[i].style.left=xp+xb*Math.cos(sb+i*e*Math.PI/180);
pb[i]=txtaress[i].style.pixelTop-yp;
pa[i]=pb[i]-pb[i]*2;
if (pa[i] < 1){
pa[i]=0;
txtaress[i].style.visibility='hidden';
}
else txtaress[i].style.visibility='visible';
txtaress[i].style.fontSize=pa[i]/2.7;
}
sb-=sa;
setTimeout('ani()',60);  //设置转动的速度
}
window.onload=ani;
}
// -->
</SCRIPT>
</head>
<body>
</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?