How to set SmoothScroll Offset ?


Topic: How to set SmoothScroll Offset ?

Giovanni De Stefano (zxxz) pro asked 2 years ago

Hello, I am using a fixed top nav bar. How can I set the offset for SmoothScroll? I see the option available in Angular version but not in the jQuery version (I have the pro version of both). Thank you, Giovanni

Bartłomiej Malanowski staff pro premium answered 2 years ago

Hi, Giovanni! Please add data-offset="<any value you want>" to your <a> element. Here's an example:
<ul class="nav nav-pills default-pills smooth-scroll">
    <li class="nav-item"><a class="nav-link" href="#sectionOne" data-offset="100">Section with offset</a></li>
    <li class="nav-item"><a class="nav-link" href="#sectionTwo">No offset</a></li>

Giovanni De Stefano (zxxz) pro commented 2 years ago

Hello Bartłomiej, Thank you so much!!!! ? It works perfectly! Cheers, Giovanni

Please insert min. 20 characters.


Specification of the issue
  • User: Pro
  • Premium support: No
  • Technology: jQuery
  • MDB Version: 4.5.9
  • Device: Any
  • Browser: Any
  • OS: Any
  • Provided sample code: No
  • Provided link: Yes