0

My header doesn't appear anywhere. I would like to know how to fix it.

body {
  background-color: antiquewhite;
  font-size: 100%;
  width: 100%;
  height: auto;
}
nav {
  height: 8%;
  width: 100%;
  position: fixed;
  display: block;
  background-color: grey;
  z-index: 1000;
}
header {
  width: 100%;
  background-image: url("https://placehold.it/50/50");
}
<nav>
  <h1>...</h1> 
</nav>

<header>
</header>
Paul Roub
  • 36,322
  • 27
  • 84
  • 93
SRomie
  • 67
  • 1
  • 1
  • 7

3 Answers3

4

This would do the trick:

html, body {height:100%;}

if you use percentage for height the parent needs to have a fixed height (so actually it's 8% of something) or at least ALL parents till html tag need to have a percentage height.

Alvaro Menéndez
  • 8,766
  • 3
  • 37
  • 57
0

My first thought would be give that header element some (html-)content (like text) or specify a height explicitly as of my experience container elements are not "shown" when their boundaries are not declared in any way.

Otherwise you may have a look here as this seems to be the same problem basically to me.

If you are using e.g. Firefox, you can use rightclick->inspect element to see if the element is simply not rendered (i.e. because of no height) or otherwise trace the applied css, manipulate css in place (non permanent) or even debug javascript.

Hope this helps.

Community
  • 1
  • 1
DMuenstermann
  • 31
  • 1
  • 3
0

The header tag has no contents, and therefore 0 height. Try adding some text inside the header tags or add a height with css.

DraganAscii
  • 322
  • 1
  • 9