I have an element that follows the page when scrolled however say when I minimize the page and scroll, the element goes above and below where I want it to. Is there anyway to state scroll limits so it doesn't go above or below certain parts of the page. So basically I want it to stop before the header and footer of my page, but follow the page when in the body.
Asked
Active
Viewed 150 times
0
-
do you have any code? – Millard Mar 12 '14 at 17:19
-
You should be able to do this by getting the position of the bottom part of the header and the top part of the footer (http://stackoverflow.com/questions/288699/get-the-position-of-a-div-span-tag) and then you'll have the areas that you don't want it to traverse into. But as Tom stated, it will be easier if you give it a shot and then give us code to show where the problem is in this process. – gregwhitworth Mar 12 '14 at 17:22
1 Answers
0
You may benefit from the JQuery .scrollTop() method.
Description: "Get the current vertical position of the scroll bar for the first element in the set of matched elements or set the vertical position of the scroll bar for every matched element."
Reference: scrollTop

Derek Story
- 9,518
- 1
- 24
- 34