|
@@ -0,0 +1,31 @@
|
|
|
+<!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: 50px;
|
|
|
+ background-color: red;
|
|
|
+ }
|
|
|
+ </style>
|
|
|
+</head>
|
|
|
+<body>
|
|
|
+ <div class="box"></div>
|
|
|
+ <script>
|
|
|
+ var oBox = document.getElementsByClassName("box")[0];
|
|
|
+
|
|
|
+ // setTimeout(function(){
|
|
|
+ // oBox.style.width = "400px"
|
|
|
+ // },2000)
|
|
|
+
|
|
|
+ // offsetWidth 获取元素的宽度
|
|
|
+ // offsetHeight 获取元素高度
|
|
|
+ setInterval(function(){
|
|
|
+ oBox.style.width = oBox.offsetWidth + 10 +"px";
|
|
|
+ },16)
|
|
|
+ </script>
|
|
|
+</body>
|
|
|
+</html>
|