Change justify-content value when flex items overflow container

justify-content is not the right approach to center because of the problem you describe. Instead, I recommend auto margins. You can use them to center: Prior to alignment via justify-content and align-self, any positive free space is distributed to auto margins in that dimension. And they behave as you want with overflow: Overflowing boxes ignore … Read more

Change div order with CSS depending on device-width

This is doable in CSS thanks to the wonderful flexbox spec. Using the order and flex-flow properties, we can achieve what you want. Unprefixed, IE11 and all evergreen browsers will support this. IE10 prefixes -ms-order and doesn’t support flex-flow. The solution takes into consideration all the constraints you listed: Have a list of elements in … Read more

Difference between width: 50% and flex: 50% in a CSS flexbox?

There is no effective difference in this instance. In fact, it’s because flex is shorthand for flex-grow, flex-shrink and flex-basis combined. flex-basis defines the default size of an element before the remaining space is distributed. So in this case, you have defined all a children` to 50%. Reference Article: http://css-tricks.com/snippets/css/a-guide-to-flexbox/

Why is padding expanding a flex item?

The calculations are defined in the spec. A flex item’s size with padding and flex-grow is determined by calculations in the flexbox spec. These calculations are similar to the sizing of flex items with padding and flex-shrink. Frankly, the math is quite technical and not the easiest thing in the world to understand. But if … Read more

flex property messes with button height?

Flexbox make items same height as you can see here Demo , but you can use align-items to change that or in your case Demo .parent { align-items: center; display: flex; } .child { border: 1px solid black; margin: 5px; } .child:first-child { height: 100px; } <div class=”parent”> <div class=”child”>Child</div> <div class=”child”>Child</div> </div>

Flexbox – align-self: flex-end horizontally

align-self: flex-end; only goes “column”, in your case you have two options: justify-content: space-between; on .container, fiddle remove the align-self on both elements and use margin-left: auto; on .b, fiddle .container { border: 2px solid; height: 500px; display: flex; flex-direction: row; justify-content: space-between; } .box { border: 1px solid; height: 200px; width: 50px; } .a … Read more