π This is a super simple mobile focused navbar.
π Understand your navigation, avoid unwanted bugs.
π Auto scroll to sections on mobile without having to build weird interactions.
π Easily integrate it into your favourite build method (Β client-first, wizardry )
1.) Copy the entire nav__bar into your project
2.) Make sure to keep the embedded CSS in it! (Β or put the code your own CSS )
3.) Copy this and paste this jQuery code into the before <body></body>
4.) Don't forget to put it into a <script></script> tag π
π We basically just remove / add the ".nav__closed" class on the ".nav__trigger"
π But how is this possible? With good ol' CSS inheritance.
π These two lines ".nav__line" have simple CSS transforms on them
π Their initial state is determined by the ".nav__closed" combo class on their parent ".nav__trigger"
π Okay so far, it's nothing special, but here's the kicker that changed my life,
the magic wave symbol "~" β€οΈ
π This one is called General sibling combinator and it does exactly what it says, it targets an elements sibling. BUT in order to get it two work make sure that it's above the ".nav__wrapper"
π Okay you might say, nice but this version is super lame IΒ want the menu to come in from the top or from the bottom or from the the right instead of the left and so on... just change the transform value in the nav__css
π You can also change the easing of the ".nav__wrapper" in the transform panel
π Hope it's useful to you. Enjoy π₯³