I'm struggling with getting my header area to behave the way I want when shrinking and enlarging the website. The header should be fully responsive.
What I want
The header consists of three parts:
|-------------------|----------------------------------------------|--------------|
||-----------------|| ||------------||
|| The site logo || A text message ||Another logo||
||-----------------|| ||------------||
|-------------------|----------------------------------------------|--------------|
I want the rules to be like this:
- The logo is 40% of the document width but can't be wider than 400 px. This is done with
width
andmax-width
. Height is dynamic/auto. - The text message column is gonna be as wide as it can be, but don't have any fixed width.
- The other logo to the right is gonna be 100% height of the column, which is based of the height of the site logo to the left.
The problem
The problem is that it seems impossible to get that logo to the right to be 100% in height without being as big as the entire document. I want it to have the height of the column as if the logo wasn't in there.
What I've tried
I've tried both the table solution ("div
with display:table
") and the flex grid solution (div
with display:flex
). The latest mentioned is the one I'm currently struggling with.
body {
font-family: Roboto, Arial, Helvetica, sans-serif;
font-size: 14px;
color: #fff;
background: #20262e;
}
.container {
display: flex;
flex-direction: row;
}
.col {
vertical-align: middle;
background: hsla(0,0%,100%,.1);
margin:2px;
padding:10px;
}
.col.logo {
width: 40%;
max-width: 400px;
}
.col.logo img {
width: 100%;
height: auto;
}
.col.game-host-logo img {
width:auto;
max-width: 100%;
height: 100%;
}
<div class="container">
<div class="col logo">
<img src="https://dromfemman.se/assets/img/dromfemman_logo.png" />
</div>
<div class="col live-msg">
Text Message
</div>
<div class="col game-host-logo">
<img src="https://dromfemman.se/assets/img/ssl_logo.svg" />
</div>
</div>