Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Modern Web Developer tools (in Chrome / FF / IE, eg.) provide a way to see the "Box Model" and "Computed CSS Properties" of a particular element. However;

Is there a way to monitor the final computed/layout position easily with such tools?


Preferably absolute, but within the parent container is also suitable. I am amendable to using any of the previously mentioned [Windows] browsers, but prefer to use Chrome.

like image 939
user2864740 Avatar asked Nov 08 '14 19:11

user2864740


People also ask

How do you find the position of an element in Chrome?

Using the Chrome browser, right click / control click anywhere inside your content area and select Inspect Element. In Chrome, right-click (or control + click) in the content area and choose "Inspect Element" to open the element inspector.

How do I find the HTML element of a browser?

If you have a browser such as Chrome, Firefox, or Safari, Inspect element is available from the context menu when you right click on the webpage (shown here in Chrome). To find the HTML ID or Name for a specific element you can: Right-click on the element. Click on Inspect within the popup menu.

Where can we view the HTML attributes for a web element in the Chrome browser?

Method 1: Inspect Element Using Chrome Developer Tools At the top right corner, click on three vertical dots. From the drop-down menu, click on More tools -> Developer Tools. macOS users can use the shortcut – command + option + C and Windows users can use Control + Shift + C.


2 Answers

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 }

like image 89
Wayne Maurer Avatar answered Oct 01 '22 16:10

Wayne Maurer


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

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

like image 23
dwilson Avatar answered Oct 01 '22 15:10

dwilson