Creating a Sticky Header in CSS


Keep the header fixed at the top of the viewport during scrolling.

Source Code

.sticky-header {
    position: sticky;
    top: 0;
    background-color: #ccc;
    padding: 10px 0;
    z-index: 1000;
}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments