The aim is to own the navigation mounted once user scrolling the page and back to its original position once scrolling back to high.
Click here to view demo of the fixed menu while scrolling down of the page.
There area unit scores of tutorial out there within the web however it contains scores of JS code thus i made a decision to make my very own means and with solely some lines of JS code, during this tutorial I solely use a pair of JS functions to create the mounted menu operating, affirmative solely 2 functions.
Ok, let’s begin.
All we'd like is just jQuery library; you'll be able to transfer it in jQuery web site or use different library from Google CDN, Miscrosoft CDN and jQuery CDN.
This contains our menu hypertext markup language component, this can be simply an easy hypertext markup language UL tag to create our menus however if you have already got one then use that instead.
If you’re progressing to use your previous menus check that to exchange the class in JS code.
To make our menu list horizontally we want to feature CSS code.
We set the z-index terribly high since we have a tendency to don’t need the other absolute part to get on high of our navigation and add with in p.c to center menu whereas scrolling.
This tiny JS code contains the most functions of our mounted scroll menu.
So, if we have a tendency to ar on the highest but 136 height in constituent the menu is within the original position and add f-nav CSS category once larger than 136px height or add f-nav CSS category on scroll, wherever the highest page larger than 136px height.
That’s it, its simple right? Enjoy!