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

What are the ways to get element offset in javascript_javascript tips

WBOY
Release: 2016-05-16 16:43:18
Original
1456 people have browsed it

The offset of the element can be obtained through four attributes:

1. offsetHeight: The size of the space occupied by the element in the vertical direction, (pixels). This includes the height of the element, the height of the (visible) horizontal scroll bar, the height of the top border, and the height of the bottom border.

2. offsetWidth: The size of the space occupied by the element in the horizontal direction, (pixels). Includes the width of the element, the height of the (visible) vertical scrollbar, the height of the left border and the height of the right border.

3. offsetLeft: the pixel distance between the left outer border of the element and the left inner border of the containing element;

3. offsetTop: the pixel distance between the top outer border of the element and the top inner border of the containing element;

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