Jump to content

Keep Menu While Scrolling

Recommended Posts

  • Replies 4
  • Created
  • Last Reply

Here you are. Insert this via the CSS Editor:

@media only screen and (min-width: 767px) {
    #header {
        position: sticky;
        top: 0;
        z-index: 9999;
        background-color: #F0F4F4;
    }
}

A few notes:

  • This doesn't affect the mobile header/navigation. To do that properly, you'd need to use JavaScript.
  • If at some point your body background color becomes different than your header color, things would get more complicated.
  • The code above will work in modern browsers, but not older ones. Older ones will simply have the non-fixed header (not a big deal).

If a response helped you out, send a 'Like' 👍 (bottom-right) and/or 'Upvote' vote.jpg.c260784ece77aec852b0e3049c77a607.jpg (top-left)

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.