颜色渐变

颜色渐变:

代码
<!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=utf-8" />
<style type="text/css">
#block
{ width:400px;}
</style>
<script type="text/javascript">
    window.onload
=function(){
        document.getElementById(
"block").style.backgroundColor="#ffffff";
        setTimeout(
"colorFlash(255)",300);
    }
    
    
function colorFlash(newColor){
        
var hexVal=newColor.toString(16);
        
        
if(hexVal.length<2){
            hexVal
="0"+hexVal;
        }
        
        
var colorString="#ffff"+hexVal;
        
var blockDiv=document.getElementById("block");
        blockDiv.style.backgroundColor
=colorString;
        
if(newColor>0){
            newColor
-=5;
            setTimeout(
"colorFlash("+newColor+")",50);
        }
    }
</script>
</head>
<body>
<div id="block">
<p>hello</p>
</div>
</body>
</html>

 

 

posted @ 2010-06-21 13:46  Fskjb  阅读(301)  评论(0编辑  收藏  举报
年年行好运