Home  >  Article  >  Web Front-end  >  javascript quick way to get element position getBoundingClientRect()_javascript tips

javascript quick way to get element position getBoundingClientRect()_javascript tips

WBOY
WBOYOriginal
2016-05-16 18:41:011592browse

It returns an object that contains four attributes: left, right, top, and bottom, which respectively correspond to the distance between the upper left corner and lower right corner of the element relative to the upper left corner of the browser window (viewport).
So, the relative position of the web page element is
var Get the absolute position
var , Opera 9.5 all support this method, but Firefox 2.x, Safari, Chrome, and Konqueror do not support it.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn