Skip to content

Menu sticky #58

Answered by markteekman
jaroslavhuss asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @jaroslavhuss,

I did a project on Frontend Mentor once and made the menu sticky when the user scrolls up. Just a little CSS and JavaScript was used in the Header.astro component, you can check it out here: https://github.com/markteekman/sunnyside-agency-landing-page/blob/master/src/components/Header.astro.

Otherwhise you can set these Tailwind classes to the <header> tag in your Header.astro component:

<header class="sticky top-0 z-30">

Make sure to also set the dark/light background color for the header depending on whether darkmode is enabled or not.

Hope this helps!

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by markteekman
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants