div动画展开
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>title</title>
<style>
* {
margin: 0;
padding: 0;
}
div {
width: 200px;
height: 150px;
background-color: red;
border-radius: 100px;
}
</style>
</head>
<body>
<input type="button" value="展开" id="btn"/>
<div id="div"></div>
<script>
document.getElementById("btn").onclick = function () {
var width = 200;
var timeId = setInterval(function () {
width+=10;
if(width==800){
clearInterval(timeId);
}
document.getElementById("div").style.width=width+"px";
}, 20);
};
</script>
</body>
</html>