I have set up a flexbox with two items which should be on the left and right on a normal screen.
If the screen is not big enough to show both next to each other, it should wrap but then they should be centered and not aligned on the left.
I tried different solutions (like using margin: auto on the child items) but that aligned them more to the center even when in the same row.
Here is a simplified example:
.container { display: flex; align-items: flex-end; flex-wrap: wrap; justify-content: space-between; border: 1px solid black; margin-bottom: 25px;}.large { width: 500px;}.small { width: 175px;}.item { width: 100px; height: 100px; background-color: blue; margin: 25px 0px;}<div class="container large"><div class="item"></div><div class="item"></div></div><div class="container small"><div class="item"></div><div class="item"></div></div>https://jsfiddle.net/SoWhy/zfx4ub8x/
The first container is the intended positioning, the second container emulates the same container on a smaller screen, note the align to the left.
Is there a way to define that the flexbox is to align items differently when wrapped or can I only do it using the "@media screen" method (which requires me to set a certain size and is thus not flexible if the size of the items changes)?