I am trying to vertically center the content of two divs (image-container & text-container) that I am aligning side-by-side one another using flex. The div on the left contains a fixed image, the contents of the div on the right is variable - it may contain a single div or many divs.
Here is the html:
.alert-container {
display: flex;
justify-content: start;
min-width: 100%;
min-height: 3rem;
margin: 0;
padding: 0 0 0 5px;
border: 1px solid rgb(243, 165, 70);
border-radius: 5px;
background-color: #FEE1BD;
}
.image-container {
/* this seems to work */
display: flex;
align-items: center;
}
.text-container {
/* I cannot figure out what to do here to vertically center the contents.
Also, the child divs inside this container need to each be on their own
row. */
}
img {
max-height: 70px;
}
<!-- This version only a few div children inside text-container
Note that the image is centered vertically
But the text isn't -->
<div class="alert-container">
<div class="image-container">
<img src="http://2.bp.blogspot.com/-pfDiDXn-GKA/TaN3OtJC2YI/AAAAAAAAEE8/mrp-RKgEWgw/s1600/ExclamationPoint-main_Full.jpg" />
</div>
<div class="text-container">
<div>
<div>The content inside the</div>
<div>parent div is variable</div>
<div>there may be 1, 2, 3, or more divs</div>
</div>
</div>
</div>
<!-- This version has many div children inside text-container
Note that the image is centered vertically
But the text isn't -->
<div class="alert-container">
<div class="image-container">
<img src="http://2.bp.blogspot.com/-pfDiDXn-GKA/TaN3OtJC2YI/AAAAAAAAEE8/mrp-RKgEWgw/s1600/ExclamationPoint-main_Full.jpg" />
</div>
<div class="text-container">
<div>
<div>The content inside the</div>
<div>parent div is variable</div>
<div>there may be 1, 2, 3, or more divs</div>
<div>...</div>
<div>...</div>
<div>...</div>
<div>...</div>
<div>...</div>
</div>
</div>
</div>