逐渐变色的文字特效

发布时间:2015-2-19 18:26:47 作者:小五 点击:

<!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>
<style>
.box{
position:relative;
width:1000px;
}
.comm{
font-size:60px;
color:#ddd;
font-family:黑体;
position: absolute;
top:0;
left:0;
}
.red{
color: #0000FF;
width: 0;
overflow: hidden;
white-space: nowrap;
z-index: 10;
};
</style>
</head>
<body>
<div class="box">
<strong id="Title" class="comm">网页教学网www.comingcoin.com</strong>
</div>
<script>
function getStyle( elem, name )
{
if (elem.style[name])
return elem.style[name];
else if (elem.currentStyle)
return elem.currentStyle[name];
else if (document.defaultView && document.defaultView.getComputedStyle) {
name = name.replace(/([A-Z])/g,"-$1");
name = name.toLowerCase();
var s = document.defaultView.getComputedStyle(elem,"");
return s && s.getPropertyValue(name);}
else return null;
}
(function(){
var lb = document.getElementById("Title"),
lt = lb.cloneNode(true),
i = 0,
sw = parseInt(getStyle(lb,'width'));
lt.setAttribute('id',lb.getAttribute('id')+'1');
lt.className = 'comm red';
lb.parentNode.appendChild(lt);
window.sliderFont = setInterval(function(){
parseInt(getStyle(lt,'width')) >= sw ? clearInterval(window.sliderFont) : lt.style['width'] = i++ + 'px';
},10);
})();
</script>
</body>
</html>


留言列表

发表留言:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。