<h1>CSS Position: Sticky</h1>
<div class="container">
<div class="box">static</div>
<div class="box sticky">sticky</div>
<div class="box">static</div>
</div>
div.container {
display: flex;
border: 1px dashed red;
position: relative;
height: 120vh;
}
div.box {
height: 100px;
width: 100px;
border: 2px solid lightskyblue;
text-align: center;
background-color: lightgoldenrodyellow;
border-radius: 10px;
margin: 5px;
}
div.sticky {
position: -webkit-sticky;
position: sticky;
background-color: lightblue;
top: 0px;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.