So I was working on making a sticky nav once you scroll past the hero. I've had no issues using element.offsetTop
before. But I'm trying to find a way to do it for the bottom of the element. element.offsetBottom
doesn't seem to be a thing. So is there a way to track the bottom on an element in JS?
element.offsetTop
is a distance from the element to the nearest positioned element.offsetParent
.
So if you want to calculate the distance from element.offsetParent
to element bottom edge, if I understand you correctly, you can just
element.offsetBottom = element.offsetTop + element.offsetHeight