代码语言:javascript复制
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style type="text/css">
*{margin: 0;padding: 0;list-style: none}
div{width: 200px;height: 200px;
position: absolute;left: 0;top: 0;right: 0;bottom: 0;margin: auto;background: -webkit-linear-gradient(45deg,red,yellow,green);
}
</style>
</head>
<body>
<div ID="div1"></div>
<script type="text/javascript">
var deg=45;
setInterval(function()
{
deg ;
div1.style.background='-webkit-linear-gradient(' deg 'deg,red,yellow,green)'
},16);
</script>
</body>
</html>
代码语言:javascript复制<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style type="text/css">
*{margin: 0;padding: 0;list-style: none}
div{width: 200px;height: 200px;
position: absolute;left: 0;top: 0;right: 0;bottom: 0;margin: auto;background: -webkit-radial-gradient(red 10%,green,yellow);
}
</style>
</head>
<body>
<div id="div1"></div>
<script type="text/javascript">
var deg=0;
setInterval(function()
{
deg ;
div1.style.background='-webkit-radial-gradient(red ' deg '%,green,yellow)'
},16);
</script>
</body>
</html>