Home  >  Article  >  Web Front-end  >  What are the ways to get element offset in javascript_javascript tips

What are the ways to get element offset in javascript_javascript tips

WBOY
WBOYOriginal
2016-05-16 16:43:181411browse

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;

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