Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

137
Views
How can I offset a single link in Scrollspy navigation?

I'm using the Boostrap scrollspy for my onpage navigation.

Every link has an offset of 70 pixels. But for one single nav item I need a different offset of 140 pixels.

Is there a way to do this?

$(function() {
  $('body').scrollspy({
    target: '#scrollnav',
    offset: 70,
  });
});
#scrollnav {position: sticky; top:0;}
.nav-link.active {background: blue; color:#fff;}
.content {height: 1500px; padding: 140px 16px;}
.content-1 {padding: 70px 16px;}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/css/bootstrap.min.css" integrity="sha384-zCbKRCUGaJDkqS1kPbPd7TveP5iyJE0EjAuZQTgFLD2ylzuqKfdKlfG/eSrtxUkn" crossorigin="anonymous">

<nav id="scrollnav">
  <ul class="nav">
    <li class="nav-item">
      <a class="nav-link page-scroll" href="#link_1">First Link with only 20px offset</a>
    </li>
    <li class="nav-item">
      <a class="nav-link page-scroll" href="#link_2">Second Link</a>
    </li>
    <li class="nav-item">
      <a class="nav-link page-scroll" href="#link_3">Third Link</a>
    </li>
  </ul>
</nav>

<div id="link_1" class="content content-1">First Link with only 20px offset</div>
<div id="link_2" class="content">Second Link</div>
<div id="link_3" class="content">Third Link</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-fQybjgWLrvvRgtW6bFlB7jaZrFsaBXjsOMm/tB9LTS58ONXgqbR9W8oWht/amnpF" crossorigin="anonymous"></script>

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!