A sticky element toggles between relative
and fixed
, depending on the scroll position. It is positioned relative until a given offset position is met in the viewport – then it “sticks” in place (like position:fixed).
HTML
<img src="text.jpg" class="sticky" alt="img">
CSS
.sticky{
position: -webkit-sticky;
position: sticky;
top: 0;
width: 200px;
}
Be the first to post a comment.