pageX/Ygives the coordinates relative to the<html>element in CSS pixels.-
clientX/Ygives the coordinates relative to the viewport in CSS pixels. screenX/Ygives the coordinates relative to the screen in device pixels.
pageX/Y提供了相对于<html>元素的以CSS像素度量的坐标。

clientX/Y提供了相对于viewport的以CSS像素度量的坐标。

screenX/Y提供了相对于屏幕的以设备像素进行度量的坐标。

90%的时间你将会使用pageX/Y;通常情况下你想知道的是相对于文档的事件坐标。其他的10%时间你将会使用clientX/Y。你永远不需要知道事件相对于屏幕的坐标。
本文详细解释了网页坐标系中的pageX/Y、clientX/Y与screenX/Y的含义及用法,重点阐述了在不同场景下选择使用哪种坐标系的重要性。
1024

被折叠的 条评论
为什么被折叠?



