Get bottom position of element javascript

Get bottom position of element javascript :

1. Get offsetTop 

2. get offsetHeight

3. bottomPosition = offsetTop + offsetHeight

let el = document.querySelector('element')

let bottomPosition = el.offsetHeight + el.offsetTop 


The offsetHeight property returns the viewable height of an element in pixels, including padding, border and scrollbar, but not the margin.


The reason why the "viewable" word is specified, is because if the element's content is taller than the actual height of the element, this property will only return the height that is visible (See "More Examples").


Note: To understand this property, you must understand the CSS Box Model.


Tip: This property is often used together with the offsetWidth property.


Tip: Use the clientHeight and clientWidth properties to return the viewable height and width of an element, only including the padding.


Tip: To add scrollbars to an element, use the CSS overflow property.


This property is read-only. 

Posting Komentar

0 Komentar