When working with css flexbox
, the behavior of the main browsers can vary significantly in certain aspects.
For example, I am attempting to build a grid of images:
<div class="container">
<div class="photo"></div>
<div class="photo"></div>
<div class="photo"></div>
<div class="photo"></div>
<div class="photo"></div>
<div class="photo"></div>
</div>
.container {
display:inline-flex;
flex-flow : column wrap;
align-content : flex-start;
height : 100%;
}
In this scenario, I require a container with multiple div
elements that flow vertically and wrap when needed to create columns of photos.
The challenge is to ensure the container expands horizontally to fit the wrapped elements:
For a visual representation, check out this jsFiddle.
Here's how each browser behaves:
- IE 11 - The container expands horizontally to wrap each column of elements effectively.
- Firefox - The container only wraps the first column with the remaining overflowing out.
- Chrome - The container always stretches to fill the width of its parent element.
In this case, I aim to achieve IE11's behavior in Firefox and Chrome. So, the question remains: How can I make a flexbox
container expand horizontally to match its column wrap
elements?
Appreciate your insights.