<div class="wrapper">
    <div class="sticky">sticky1</div>
  </div>
  <div class="wrapper">
    <div class="sticky">sticky2</div>
  </div>
  <div class="wrapper">
    <div class="sticky">sticky3</div>
  </div>
  <div class="wrapper">
    <div class="sticky">sticky4</div>
  </div>

.wrapper{
  height: 400px;
  border: 1px solid red;
  margin-bottom: 10px;
}
.sticky{
  top: 0px;
  position: sticky;
  background-color: #ddd;
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.