Bootstrap class: .navbar sticky-top

<nav class="navbar sticky-top navbar-dark bg-primary">
  <a class="navbar-brand" href="#">Sticky top</a>
</nav>

Preview

More in Bootstrap Navbar