Don't want to learn Bootstrap classes? Go to Bootstrap builder for busy developers.

Bootstrap class: .sticky-top

<div class="sticky-top bg-primary">Sticky top</div>

Preview

Sticky top

Sass source

/* _position.scss:31 */
.sticky-top {
  @supports (position: sticky) {
    position: sticky;
    top: 0;
    z-index: $zindex-sticky;
  }
}

Uses variables

/* _position.scss:31 */
$zindex-sticky