0

When I have a navbar as seperate div, how can I make the header full height of the screen? When I add 100vh it's too big, when users lands on website he can scroll. I need to add like 95.5vh instead to fit it perfectly, but I do not want to add custom height. How can I make it to be full height all time no matter the size of navbar? Is there something else than vh I could use?

header {
  background: red;
  height: 100vh;
}

body {
  margin: 0;
}
  <div class="navbar">
    <div class="navbar__logo">Brand.</div>
  </div>
  <header>
    Hello
  </header>
Dave
  • 1
  • 1
  • 9
  • 38

1 Answers1

1

Using flex, flex-direction and flex-grow does the job well.

Guide to Flexbox would be a good reading to have. Then seach MDN for more detail of each property.

body{
  display: flex;
  flex-direction: column;
  height: 100vh;
  margin: 0;
}

header {
  background: red;
  flex-grow: 1;
}
<div class="navbar">
  <div class="navbar__logo">Brand.</div>
</div>
<header>
  Hello
</header>
Louys Patrice Bessette
  • 33,375
  • 6
  • 36
  • 64