|
@@ -0,0 +1,54 @@
|
|
|
+<!DOCTYPE html>
|
|
|
+<html lang="en">
|
|
|
+<head>
|
|
|
+ <meta charset="UTF-8">
|
|
|
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
|
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
+ <title>Document</title>
|
|
|
+ <style>
|
|
|
+ *{
|
|
|
+ margin: 0;
|
|
|
+ padding: 0;
|
|
|
+ }
|
|
|
+ #div1{
|
|
|
+ width: 200px;
|
|
|
+ height: 200px;
|
|
|
+ background: red;
|
|
|
+ transition: width 2s linear;
|
|
|
+ }
|
|
|
+ </style>
|
|
|
+</head>
|
|
|
+<body>
|
|
|
+ <button id="up">放大</button>
|
|
|
+ <div id="div1"></div>
|
|
|
+ <button id="down">缩小</button>
|
|
|
+ <script>
|
|
|
+ // var up = document.getElementById('up')
|
|
|
+ // var div1 = document.getElementById('div1')
|
|
|
+ // var down = document.getElementById('down')
|
|
|
+ // up.onclick = function(){
|
|
|
+ // var timer = setInterval(function(){
|
|
|
+ // console.log(div1.offsetWidth)
|
|
|
+ // if(div1.offsetWidth < 500){
|
|
|
+ // div1.style.width = div1.offsetWidth + 10 +'px'
|
|
|
+ // } else {
|
|
|
+ // clearInterval(timer)
|
|
|
+ // }
|
|
|
+ // },10)
|
|
|
+ // }
|
|
|
+ // down.onclick = function(){
|
|
|
+ // var timer = setInterval(function(){
|
|
|
+ // console.log(div1.offsetWidth)
|
|
|
+ // if(div1.offsetWidth > 0){
|
|
|
+ // div1.style.width = div1.offsetWidth - 10 +'px'
|
|
|
+ // } else {
|
|
|
+ // clearInterval(timer)
|
|
|
+ // }
|
|
|
+ // },10)
|
|
|
+ // }
|
|
|
+ up.onclick = function(){
|
|
|
+ div1.style.width = '500px'
|
|
|
+ }
|
|
|
+ </script>
|
|
|
+</body>
|
|
|
+</html>
|