Home > Web Front-end > JS Tutorial > body text

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

WBOY
Release: 2016-05-16 18:41:01
Original
1586 people have browsed it

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.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!