My goal is to showcase images on a flexbox grid, and while it works perfectly in Chrome, I'm encountering issues in Firefox (uncertain where the problem lies).
Check out the CodePen link for reference : https://codepen.io/anon/pen/QJNajw?editors=1100
Chrome:
https://i.sstatic.net/2Qmhc.png
Firefox:
https://i.sstatic.net/9JfCD.png
The concept behind the CSS is to initially have the grid cells occupy all available space, before allowing the images to fill these cells without distortion.
However, in Firefox, it seems like the images are simply taking up the entire available width, causing an overflow issue. (It's worth noting that in the second grid, the layout leans more towards being wider than taller, preventing vertical overlap when the images consume the available width.)
Is there a way to resolve this discrepancy and make it align with the intended design in Firefox?
.grids {
display: flex;
}
.grid {
display: flex;
flex-direction: column;
background: #ddd;
box-sizing: border-box;
border-radius: 10px;
margin: 5px;
padding: 2px;
width: 120px;
height: 120px;
}
.row {
display: flex;
justify-content: center;
flex-grow: 1;
flex-basis: 0;
}
.cell {
display: flex;
flex-grow: 1;
flex-basis: 0;
justify-content: center;
align-items: center;
box-sizing: border-box;
height: 100%;
padding: 2px;
}
.cell img {
display: block;
max-width: 100%;
max-height: 100%;
object-fit: contain;
}
<div class="grids">
<div class="grid">
<div class="row" style="padding: 0px 16.6667%;">
<div class="cell"><img src="https://img.icons8.com/wired/80/000000/circled-user.png"></div>
<div class="cell"><img src="https://img.icons8.com/wired/80/000000/circled-user.png"></div>
</div>
<div class="row" style="padding: 0px 0%;">
<div class="cell"><img src="https://img.icons8.com/wired/80/000000/circled-user.png"></div>
<div class="cell"><img src="https://img.icons8.com/wired/80/000000/circled-user.png"></div>
<div class="cell"><img src="https://img.icons8.com/wired/80/000000/circled-user.png"></div>
</div>
<div class="row" style="padding: 0px 16.6667%;">
<div class="cell"><img src="https://img.icons8.com/wired/80/000000/circled-user.png"></div>
<div class="cell"><img src="https://img.icons8.com/wired/80/000000/circled-user.png"></div>
</div>
<div class="row" style="padding: 0px 0%;">
<div class="cell"><img src="https://img.icons8.com/wired/80/000000/circled-user.png"></div>
<div class="cell"><img src="https://img.icons8.com/wired/80/000000/circled-user.png"></div>
<div class="cell"><img src="https://img.icons8.com/wired/80/000000/circled-user.png"></div>
</div>
</div>
<div class="grid">
<div class="row" style="padding: 0px 37.5%;">
<div class="cell"><img src="https://img.icons8.com/wired/80/000000/circled-user.png"></div>
</div>
<div class="row" style="padding: 0px 25%;">
<div class="cell"><img src="https://img.icons8.com/wired/80/000000/circled-user.png"></div>
<div class="cell"><img src="https://img.icons8.com/wired/80/000000/circled-user.png"></div>
</div>
<div class="row" style="padding: 0px 12.5%;">
<div class="cell"><img src="https://img.icons8.com/wired/80/000000/circled-user.png"></div>
<div class="cell"><img src="https://img.icons8.com/wired/80/000000/circled-user.png"></div>
<div class="cell"><img src="https://img.icons8.com/wired/80/000000/circled-user.png"></div>
</div>
<div class="row" style="padding: 0px 0%;">
<div class="cell"><img src="https://img.icons8.com/wired/80/000000/circled-user.png"></div>
<div class="cell"><img src="https://img.icons8.com/wired/80/000000/circled-user.png"></div>
<div class="cell"><img src="https://img.icons8.com/wired/80/000000/circled-user.png"></div>
<div class="cell"><img src="https://img.icons8.com/wired/80/000000/circled-user.png"></div>
</div>
</div>
</div>