I have a div using the display flex method that contains other divs also using display flex to get the proper alignment that I want. I usually develop my web pages using Firefox and then later test them with other browsers to see if they work/display correctly there too.
I want to have a super-container that arranges its items in a normal flow. These items contains two images. These images are placed next to each other, and only their widths are fixed. The heights may differ per item. Below these two images I place a bit of text. All items are aligned such, that the first line of the texts are aligned with each other. The images should be placed in the horizontal middle of the item.
The following image shows how I want it to be displayed: Firefox correct display. In Chrome and Edge (and Safari on iOS), the image looks like this: Incorrect display.
I have the following HTML and CSS:
.CompleteContainer
{
align-items: baseline;
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: flex-start;
width: 300px;
}
.ItemContainer
{
align-items: center;
background-color: aqua;
display: flex;
flex-direction: column;
flex-wrap: nowrap;
margin: 0 0 5px 10px;
width: 130px;
}
.ItemTopContainer
{
display: flex;
justify-content: space-between;
width: 100%;
}
.ItemTopLeftContainer
{
align-items: flex-end;
background-color: #ff8888;
display: flex;
justify-content: flex-end;
width: calc(50% - 2px);
}
.ItemTopLeft
{
background-color: #ff0000;
height: 50px;
width: 50px;
}
.ItemTopRightContainer
{
align-items: flex-end;
background-color: #88ff88;
display: flex;
justify-content: flex-start;
width: calc(50% - 2px);
}
.ItemTopRight
{
background-color: #00aa00;
height: 25px;
width: 50px;
}
.ItemBottomContainer
{
text-align: center;
}
<div class="CompleteContainer">
<div class="ItemContainer">
<div class="ItemTopContainer">
<div class="ItemTopLeftContainer">
<div class="ItemTopLeft">
</div>
</div>
<div class="ItemTopRightContainer">
<div class="ItemTopRight">
</div>
</div>
</div>
<div class="ItemBottomContainer">
Foo bar
</div>
</div>
<div class="ItemContainer">
<div class="ItemTopContainer">
<div class="ItemTopLeftContainer">
<div class="ItemTopLeft">
</div>
</div>
<div class="ItemTopRightContainer">
<div class="ItemTopRight">
</div>
</div>
</div>
<div class="ItemBottomContainer">
Foo bar, lorum ipsum
</div>
</div>
<div class="ItemContainer">
<div class="ItemTopContainer">
<div class="ItemTopLeftContainer">
<div class="ItemTopLeft">
</div>
</div>
<div class="ItemTopRightContainer">
<div class="ItemTopRight">
</div>
</div>
</div>
<div class="ItemBottomContainer">
Lorum ipsum
</div>
</div>
</div>
What am I doing wrong or what am I missing to get the display in Chrome and Edge the same as in Firefox? To be clear: in Firefox the above code snippet gives the results I want, in Chrome and Edge (and Safari on iOS) they are wrong.
UPDATE: I am not yet allowed to comment on the answers directly, but I will do it this way. Both the answers did point me in the correct direction, though they did not produce the correct results I wanted. I have updated the code in this question to reflect the changes in CSS to create the layout I want.