zheng 16 시간 전
부모
커밋
a24a0091a9
1개의 변경된 파일44개의 추가작업 그리고 0개의 파일을 삭제
  1. 44 0
      11.复习/8.下落的树叶.html

+ 44 - 0
11.复习/8.下落的树叶.html

@@ -0,0 +1,44 @@
+<!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>
+        img {
+            position: absolute;
+            /* width: 200px; */
+        }
+    </style>
+</head>
+
+<body>
+    <!-- <img src="./img/1.png" alt=""> -->
+    <script>
+        var screenWidth = document.body.clientWidth || document.documentElement.clientWidth;
+        var screenHeight = document.body.clientHeight || document.documentElement.clientHeight;
+        function Leaf() {
+            this.width = Math.round(Math.random() * 100 + 100);
+            this.top = 0;
+            this.left = Math.random() * (screenWidth - this.width);
+            this.urls = './img/'+ Math.floor(Math.random() * 4 + 1) +'.png'
+        }
+        // 绘制图片
+        Leaf.prototype.init = function() {
+            var imgs = document.createElement('img');
+            imgs.src = this.urls;
+            imgs.style.width = this.width + 'px';
+            imgs.style.left = this.left + 'px';
+            imgs.style.top = this.top + 'px';
+            document.body.appendChild(imgs);
+        }
+        // 展示图片
+        for(let i=0;i<20;i++) {
+           let leaf = new Leaf();
+           leaf.init();
+        }
+    </script>
+</body>
+
+</html>