标题网页特效 一“码”当先──弹簧文字
栏目网络与通信
发布2001年41期
在<head>中适当位置加入如下代码:
<script language="JavaScript">
<!--
var sizes=new Array("-2px","-1px","0px","1px","2px""3px","4px")
"5px","6px","7px","8px","9px","10px","11px","12px","13px"
sizes.pos=0;
function rubberBand()
{
var el=document.all.elastic;
if(null==el.direction)
el.direction=1;
else if((sizes.pos>sizes.length-2)||(0==sizes.pos))
el.direction*=-1
el.style.letterSpacing=sizes[sizes.pos+=el.direction];
}
-->
</script>
<body>改为<body onload="setInterval('rubberBand()',150)">,然后在body后适当位置加入如下代码:
<center>
<h2 id="elastic">弹簧文字
</h2>
</center>
当然可在上述代码中加入文字的大小和颜色等,这样就会出现色彩斑斓的文字像弹簧一样左右伸缩。