HTML-CSS


Fixed navbar header on scroll page

Coding Issue for android php java html-css and javascript

Fixed headers are common nowadays with attractive layouts and design. You can use fixed navbar header on page scroll. Many brands like StackOverflow and others using this type of navbar pattern. So now we are going to learn how to fix my page header in the website.

First of all to create a fixed top menu, use position:fixed and top:0. and this fixed menu will overlay your other page content.  You can see w3school also.

Simply you need some JS to do scroll events to fixed navbar header on scroll. The best way to do this is to set a new CSS class for the fixed position that will get assigned to the relevant div when scrolling goes past a certain point.

Let’s take a few steps to do this activity:

Step 1:

In the step one create your html code. Add some required file in the head tag of the page. I the body section you need to decrilar your header with nav tag.

Step 2:

In the next step you need to create a fixed top menu, use position:fixed and top:0. Note that the fixed menu will overlay your other content. To fix this, add a margin-top (to the content) that is equal or larger than the height of your menu.

Step 3:

After doing your first two steps you need to add your Javascript code, this code helps you to archive your scroll behavior on your page.

Must Read This Also

Published by Amit Pandey

Professional Android app Developer, Full Stack Web Developer, Blogger, Entrepreneur And Founder of Coding Issue. I am always trying to learn new things or new possible ways to do things.

Did you find this page helpful?

X

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*

*