你是做到什么程度了,有哪里不会。
是功能不会实现,还是css样式的问题呢?
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title> 页面名称 </title>
<style type="text/css">
#calc {
background-color: #f90;
width: 500px;
height: 400px;
border-radius: 50px 50px 0px 0px;
padding: 5px;
}
h2 {
text-align: center;
}
</style>
</head>
<body>
<div id="calc">
<h2>简单计算器</h2>
<hr>
<input type="button" value="变色" onclick="func();" />
</div>
<script type="text/javascript">
var timer;
function func() {
var arr = ["#f00","#00f","#0f0","#fff","#ff0"];
clearInterval(timer);
function p(){
var n = Math.floor(Math.random()*arr.length);
document.getElementById("calc").style.backgroundColor = arr[n];
}
p();
timer = setInterval(p, 5000);
}
</script>
</body>
</html>