I am trying to create a navbar
that always stays at the top, which I did, but I am having problems with the content on the page that goes under it and you can't see it. I found that to fix this, I needed a 5% margin from the top of the body, but whenever I resize the width of the page, it affects the margin-top
. How would I get it so that the margin-top stays the same when resizing the width of the page? An example of what I want is the Instagram navbar (website), like how the photos don't go overlapping the fixed navbar
and on page resize it remains the same top margin.
HTML
<div>
<div className="menu">
<div className="left">
<h1>PostNote</h1>
</div>
<div className="right">
<span className="menu-item"><Link to="/">Home</Link></span>
<span className="menu-item"><Link to="/searchNotes">Notes</Link></span>
<span className="menu-item"><Link to="/addNote">Add a Note</Link></span>
<span className="menu-item"><Link to={`/users/${Meteor.userId()}`} >My Profile</Link></span>
</div>
</div>
</div>
CSS
body{
padding-left: 20%;
padding-right: 20%;
margin-top:5%;
}
.menu{
background: #F1F1F1;
width:100%;
height:10vh;
position: fixed;
left:0px;
top:0px;
z-index: 10;
}
.menu-item{
margin:5px;
font-size:1.4em;
color:black;
}