<main>
<div>position: static;</div>
<div>position: sticky;</div>
<div>position: static;</div>
</main>
main {
width: 300px;
height: 120px;
overflow: auto;
background: tomato;
}
div {
width: 200px;
height: 100px;
border: 1px solid;
background: yellow;
text-align: center;
line-height: 100px;
box-sizing: border-box;
}
div:nth-of-type(2) {
position: sticky;
top: 0;
background: cyan;
opacity: 0.8;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.