How to get the distance from the beginning of the block to the beginning of the document?
-
Let's say there is a trace structure:
<html> <body> <div class="block"></div> <div class="block"></div> <div class="block"></div> </body> <footer> <div class="footer-block"></div> <div class="footer-block-2"></div> <div class="footer-block"></div> </footer> </html>
You need to find out how many pixels are from footer-block-2 to the beginning of the document, that is, html;
The block is always static in relation to the document.JavaScript Anonymous, Feb 4, 2020 -
https://learn.javascript.com/coordinatesJoseph Wyatt
1 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!