I am encountering a specific flexbox alignment problem only in Chrome:
In the following situation, which needs to be viewed on a large screen, the two DIVs at the right (those containing header and text) should be vertically centered inside their parent container and - since the image at the left determines the height of the parent - should align to the vertical center of the image.
The parent elements relevant settings are
.container_3 {
display: flex;
flex-direction: column;
flex-wrap: wrap;
justify content: center;
height: 100%;
max-height: 480px;
}
If I erase the max-height
setting and set height
to 480px
instead of 100%, the content will center vertically also in Chrome. But in other browsers it works the way it is now, and I need that height/max-height combination for responsiveness...
Note: I left out the media queries, but the specific outer structure of three containers is due to responsiveness (the elements will wrap differently on smaller screens).
I also have that code in a codepen, but there's no difference to the code in the following snippet: https://codepen.io/anon/pen/MOLjBZ
html,
body {
height: 100%;
}
.container_1 {
display: flex;
flex-direction: column;
justify-content: center;
min-height: 100%;
border: 1px solid green;
}
.container_1 img {
display: block
}
.container_2 {
width: 100%;
max-width: 1000px;
margin: 0 auto;
border: 1px solid red;
}
.container_3 {
display: flex;
flex-direction: column;
flex-wrap: wrap;
justify-content: center;
align-items: center;
height: 100%;
max-height: 480px;
width: 990px;
border: 1px solid blue;
}
.container_3 > div {
width: 480px;
border: 1px solid yellow;
}
<div class="container_1">
<div class="container_2">
<div class="container_3">
<div class="element_1>">
<img src="http://placehold.it/400x400/dca?text=logo image"></div>
<div class="element_2>">
<h1>This is a Header</h1>
</div>
<div class="element_3>">
<p>This text, including its header, should be vertically centered due to its parent elements setting "justify content: center". That element (".container_3", blue border) has "display: flex", "flex-direction: column" and "flex-wrap: wrap").</p>
<p>This works in all browsers except Chrome...</p>
<p>The relevant detail: ".container_3" has "height: 100%;" and "max-height: 480px;". If I erase the "max-height" setting and set "height" to 480px, the content will center vertically also in Chrome. But in other browsers it works the way it is now, and i need that max-height for responsiveness...</p>
</div>
</div>
</div>
</div>