Flexbox wraps last column of the first row in Safari

DominikN. picture DominikN. · Dec 13, 2015 · Viewed 41k times · Source

The last column of the first row is wrapped to the next line when viewing in Safari, and some other iOS based browsers.

Safari:

enter image description here

Chrome / Others:

enter image description here

Code:

Answer

Taylan picture Taylan · Apr 7, 2016

Explanation

This happens because Safari treats :before and :after pseudo-elements as if they were real elements. E.g. think about a container with 7 items. If container has :before and :after Safari will position the items like this:

[:before ] [1st-item] [2nd-item]

[3rd-item] [4th-item] [5th-item]

[6th-item] [7th-item] [:after  ]

Solution

As an alternative to the accepted answer I remove :before & :after from flex containers instead of altering the HTML. In your case:

.flexthis.container:before,
.flexthis.container:after,
.flexthis.row:before,
.flexthis.row:after {
   content: normal; // IE doesn't support `initial`
}