html css js sticky navbar

How we can create a sticky slider navigation bar using HTML CSS and JS? Solution: Check out this Sticky Navbar With Sliding Underline On Scroll, Using HTML CSS JavaScript.

Previously I have shared many types of navigation bars, but this one is different from the others. Basically, the sticky navbar is kind of navigation which sticks on the top or bottom of the webpage on scrolling. Most of the popular websites use this type of menu bars, even I also use a sticky bar you have to scroll down to see that.

Today you will learn to create a menubar which sticks on the top on scrolling down. The whole design is a one-page website, there are multiple sections that you can navigate by the pressing menu items on the top. When you will scroll down then along with sticky navbar there is a sliding underline on the bottom of menu items, that shifts according to the active section.

So, Today I am sharing Sticky Navbar With Sliding Underline On Scroll. The whole program is created using HTML, CSS, and JavaScript, there is jQuery which is a JS library. In total, there is a nav or menu bar which sticks in the top on scrolling, a sliding underline on menu items, and a responsive design. This post will be very useful, you can use it for designing your website.

If you are thinking now how this sticky navigation bar actually is, then see the preview given below.

Preview Of Stick Navigation Or Menu Bar Using HTML CSS JavaScript

See this video preview to getting an idea of how this menu bar looks like.

Live Demo

Now you can see this visually, you also can see it live by pressing the button given above. If you like this, then get the source code of its.

You May Also Like:

Sticky Navbar With Sliding Underline On Scroll Source Code

Before sharing source code, let’s talk about it. First, I have created menu items using the HTML hyperlink tag, then created sections using HTML section tag. In the sections I have placed a unique ID name for each section, and in the navbar or menu item targeted the id using <a href="#ID">  method (info).

Now using CSS, I have placed all the elements. In there, I have used flex display to create a responsive design. Also, I have done so many works like text color, font style, alignment, margin, padding, etc. For fonts, used a google font and linked in the HTML file and for the small screen, I have reduced font size using CSS @media query.

In this program JavaScript handling the main functions. JavaScript handling the sticky nav on scroll feature, and the sliding underline also created using JS. Let me tell you that the sliding underline on the current page is Active Link Highlight program which I have previously shared. Left all other things you will understand after getting the codes, I can’t explain all in writing.

For creating this program you have to create 3 files. First for HTML, second for CSS, and third for the JavaScript. Follow the steps to creating this without any error.

index.html

Create an HTML file named ‘index.html‘ and put these codes given here below.

style.css

Now create a CSS file named ‘style.css‘ and put these codes given here.

function.js

The final step, Create a JavaScript file named ‘function.js‘ and put the codes.

That’s It. Now you have successfully created Sticky Navbar With Sliding Underline On Scroll, Using HTML CSS JavaScript. If you have any doubt or question comment down below.

2 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here