[英]How to calculate the distance between the top-left corner of an HTML element and the window top-left corner?
[英]How to calculate distance from top left corner (0, 0)?
如果我在頁面上有一些對象(圖像)並且我知道它們的坐標,我該如何計算左上角的距離?
這有什么不同嗎?
在偽代碼中:
dx = xposition - xcorner
dy = yposition - ycorner
distance = sqrt((dx*dx ) + ( dy*dy))
你從高中三角學課上應用畢達哥拉斯定理 。 從(0, 0)
到(55, 23)
距離是((55 x 55) + (23 x 23))
平方根。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.