Click here to Skip to main content
15,882,114 members
Please Sign up or sign in to vote.
1.33/5 (2 votes)
See more:
Hi,

I am new to html.I have menu bar that contain Home,about us,Careers,Contact us.When i scroll the page,i want to make that header with fixed position.

I write the css like this
.header{
CSS
background:black;
    position:fixed;
    width:100%;
     margin: 0 auto;
     padding:0px;
     left:0px;
     display:block;


}
It is working fine if my webpage contain only plain text.Problem is Any Images are there in my webpage that images are overcoming that header.

And In Contact us Page the Text boxes also overcoming the header part.How to solve that problem.Which Property i have to Add or remove from my css.

Thank you
Posted

1 solution

For this, you need to use,

CSS
position: absolute;
top: 0;


Now it would be fixed on top (with top co-ordinate zero). To make it stay over the images and other files and resources you should use the z-index of CSS. Like this,

CSS
z-index: 100; // suppose


Now all other elements with their z-index less than 100 would be below this element. It would float over them.
 
Share this answer
 
Comments
Member 11570261 7-Jun-15 7:50am    
It's working fine.I added
z-index:100;
position:fixed;

Thanking you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900