Browser developer tools: what is the Position of the HTML element?

混江龙づ霸主 提交于 2019-12-02 17:58:30

In Chrome, Firefox, Edge and IE11+, when an element is selected, you can access this element in the console window by typing:

$0

You can then query and manipulate using the Javascript DOM API, which has a very useful method called Element.getBoundingClientRect().

So all you have to do is type the following into the console window when an element is selected:

$0.getBoundingClientRect()

and the browser will return an object such as:

{ x: 1081, y: 72, width: 49, height: 28, top: 72, right: 1130, bottom: 99, left: 1081 }

Chrome dev tools -> Settings -> General -> Elements -> Show Rulers.

You can also install Chrome plugins that will give you a little more functionality.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!