I have the following simple HTML
and CSS
code:
body {
margin: 0;
}
.navigation {
width: 80%;
height: 15%;
margin-left: 10%;
position: fixed;
top: 0;
box-sizing: border-box;
border-style: solid;
border-width: 1px;
background-color: yellow;
}
.content {
width: 80%;
margin-top: 10%;
margin-left: 10%;
box-sizing: border-box;
border-style: solid;
border-width: 1px;
background-color: red;
}
<body>
<nav class="navigation">
<div>
Menu
</div>
</nav>
<div class="content">
<p>... </p>
<p>... </p>
<p>... </p>
</div>
</body>
First of all, sorry for the long random content but it is the only way to reproduce my issue on your local computer.
The code above displays a fixed a header and a content of a website.
You can also find all the code in the jsfiddle here.
All this works fine so far.
The idea of the above code is to be responsive so when I minimize the screen the header and content adjust automatically. In general, this seems to work.
However, for the property margin-top:10%;
I have the problem that the content goes below the fixed header
if I minimize the screen size.
Is there a way to make sure that there is always a margin between the header and the content no matter if I access the website from mobile or from the web?