I've noticed a peculiar issue when using percentage values for the height of my fixed header and margin-top of the main div.
Everything works smoothly when I set the header height to 50px
and margin-top of the main area to 50px
.
However, when I change these values to 10%
, the distance between the header and the main becomes inconsistent:
header {
position: fixed;
display: block;
top: 0px;
left: 0px;
right: 0px;
height: 10%;
background-color: green;
}
main {
margin-top: 10%;
background-color: blue;
}
<header>
My Header
</header>
<main>
Main area here!
</main>
JSFiddle: https://jsfiddle.net/azizn/L7sroo4m/
Can anyone provide an explanation for this inconsistency?