getBoundingClientReact.png

    1. <!DOCTYPE html>
    2. <html>
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
    6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    7. <title>getBoundingClientRect</title>
    8. <link rel="stylesheet" href="css/reset.min.css">
    9. <style>
    10. html,
    11. body {
    12. height: 300%;
    13. background: -webkit-linear-gradient(top left, pink, orange);
    14. }
    15. #box {
    16. position: absolute;
    17. left: 200px;
    18. top: 800px;
    19. width: 100px;
    20. height: 100px;
    21. background: red;
    22. }
    23. </style>
    24. </head>
    25. <body>
    26. <div id="box"></div>
    27. <script>
    28. let box = document.querySelector('#box');
    29. </script>
    30. </body>
    31. </html>