I have made the following layout:
html,
body {
height: 100%;
}
.header {
height: 120px;
width: 100%;
background-image: url(http://lorempixel.com/500/120/);
background-repeat: no-repeat;
background-position: center;
background-size: contain;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.3.0/css/foundation.min.css" rel="stylesheet" />
<div class="row">
<div class="columns small-12 header"></div>
</div>
It works because I have used a height-property with a fixed pixel-value.
If one removes that the image disappears:
html,
body {
height: 100%;
}
.header {
width: 100%;
background-image: url(http://lorempixel.com/500/120/);
background-repeat: no-repeat;
background-position: center;
background-size: contain;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.3.0/css/foundation.min.css" rel="stylesheet" />
<div class="row">
<div class="columns small-12 header"></div>
</div>
One of the problems with using that fixed height is that responsiveness can't be accomplished.
How can I make the background appear without having to use a fixed height? Or should I fall back to using img-tag instead?
There the height is determined by the image-sizes itself.