| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 | 
							- <!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>
 
-         .box {
 
-             width: 300px;
 
-             height: 300px;
 
-             background: #00f;
 
-         }
 
-     </style>
 
- </head>
 
- <body>
 
-     <div class="box"></div>
 
-     <br><br>
 
-     <button id="btn1">放大</button>
 
-     <br><br>
 
-     <button id="btn2">缩小</button>
 
-     <script>
 
-         var box = document.querySelector(".box")
 
-         var btn1 = document.getElementById("btn1");
 
-         var btn2 = document.getElementById("btn2");
 
-         btn1.onclick = function() {
 
-            var timer = setInterval(function(){
 
-                 if(box.offsetWidth >= 500) {
 
-                     clearInterval(timer);
 
-                 } else {
 
-                     box.style.width = box.offsetWidth + 5 + 'px';
 
-                 }
 
-             },50)
 
-         }
 
-         btn2.onclick = function() {
 
-             var timer = setInterval(function(){
 
-                 if(box.offsetWidth <= 300) {
 
-                     clearInterval(timer)
 
-                 } else {
 
-                     box.style.width = box.offsetWidth - 5 + 'px';
 
-                 }
 
-             },100);
 
-         }
 
-     </script>
 
- </body>
 
- </html>
 
 
  |