<section>
  <div id="red">box-1</div>
  <div id="green">box-2</div>
  <div id="blue">box-3</div>
</section>
section {
  margin: 10px;
  padding: 10px;
  height: 500px;
  border: 1px solid black;
}
div {
  margin-top: 100px;
  width: 50px;
  height: 60px;
  display: inline-block;
  margin-right: 20px;
}
#red {
  background-color: red;
}
#green {
  background-color: green;
}
#blue {
  background-color: blue;
  position: sticky;
  top: 0;
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.