12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <!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>
- * {
- margin: 0;
- padding: 0;
- }
- body {
- background: rgba(0, 0, 0, .3);
- }
- img {
- width: 120px;
- height: 120px;
- position: absolute;
- top: -120px;
- left: -120px;
- transition: all 2s linear;
- }
- </style>
- </head>
- <body>
- <img src="./images/1.jpg" alt="">
- <img src="./images/2.jpg" alt="">
- <img src="./images/3.jpg" alt="">
- <img src="./images/4.jpg" alt="">
- <img src="./images/5.jpg" alt="">
- <img src="./images/6.jpg" alt="">
- <img src="./images/7.jpg" alt="">
- <img src="./images/8.jpg" alt="">
- <img src="./images/9.jpg" alt="">
- <img src="./images/10.jpg" alt="">
- <img src="./images/11.jpg" alt="">
- <img src="./images/12.jpg" alt="">
- <img src="./images/13.jpg" alt="">
- <img src="./images/14.jpg" alt="">
- <img src="./images/15.jpg" alt="">
- <img src="./images/16.jpg" alt="">
- <img src="./images/17.jpg" alt="">
- <img src="./images/18.jpg" alt="">
- <img src="./images/19.jpg" alt="">
- <img src="./images/20.jpg" alt="">
- <img src="./images/21.jpg" alt="">
- <img src="./images/22.jpg" alt="">
- <img src="./images/23.jpg" alt="">
- <img src="./images/24.jpg" alt="">
- <script>
- var imgList = document.querySelectorAll("img");
- var screenWidth = document.body.clientWidth || document.documentElement.clientWidth;
- var screenHeight = document.body.clientHeight || document.documentElement.clientHeight;
- /**
- * 0 1 2 3 4 5
- * 6 7 8 9 10 11
- * 12 13 14 15 16 17
- * 18 19 20 21 22 23
- */
- var gapX = (screenWidth - 120 * 6) / 7;
- var gapY = (screenHeight - 120 * 4) / 5;
- for (var i = 0; i < imgList.length; i++) {
- var row = Math.floor(i / 6) + 1;
- var col = i % 6 + 1;
- imgList[i].style.top = row * gapY + (row - 1) * 120 + 'px';
- imgList[i].style.left = col * gapX + (col - 1) * 120 + 'px';
- imgList[i].style.transform = 'rotate('+Math.random()* 50 +'deg)';
- imgList[i].style.transitionDelay = (23-i) * 100 +'ms';
- }
- </script>
- </body>
- </html>
|