网页中的文字逐渐变色特效代码

    文章来源:万象互联 更新时间:2011-11-16 19:54:16
分享:

网页中的文字逐渐变色特效代码

让你的网站与众不同

<!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:1366px;
}
.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.hulian.top </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>

版权说明:本站原创文章,由万象互联SEO优化发表.
本文地址:https://www.hulian.top/zixun/post/4551.html
在线咨询
  • 在线时间
  • 8:00-21:00