Țaman ŞheƦzad Țaman ŞheƦzad - 1 year ago 188
CSS Question

jQuery auto scroll to elements

I came across this useful blog Smoothly scroll to an element without a jQuery plugin

In the below code

scrollTop: $("#target-element").offset().top
}, 1000);

Auto scrolls down to target-element if sliderOn id exists within the body, but, because i have a fixed navbar the target-element goes behind it and cause not to show 20px of the target-element on top. Any solution here?

Answer Source

Try this:

   scrollTop: $("#target-element").offset().top - 20
}, 1000);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download