CSS Flex Box Layout: full-width row and columns

You’ve almost done it. However setting flex: 0 0 <basis> declaration to the columns would prevent them from growing/shrinking; And the <basis> parameter would define the width of columns. In addition, you could use CSS3 calc() expression to specify the height of columns with the respect to the height of the header. #productShowcaseTitle { flex: …

Read more

What’s the difference between flex-start and baseline?

See the following two images. The code is identical for both, except for the align-items rule. align-items: flex-start align-items: baseline When using align-items or align-self, the flex-start value will align flex items at the starting edge of the cross-axis of the flex container. The baseline value will align flex items along their content’s baseline. baseline …

Read more

float does not work in a flex container

The float property is ignored in a flex container. From the flexbox specification: 3. Flex Containers: the flex and inline-flex display values A flex container establishes a new flex formatting context for its contents. This is the same as establishing a block formatting context, except that flex layout is used instead of block layout. For …

Read more

Flexbox wraps last column of the first row in Safari

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 …

Read more

Remove space (gaps) between multiple lines of flex items when they wrap

An initial setting of a flex container is align-content: stretch. This means that multiple lines of flex items will be distributed evenly along the cross axis. To override this behavior, apply align-content: flex-start to the container. When you’re working in a single-line flex container (i.e., flex-wrap: nowrap), the properties to use to distribute space along …

Read more

Is it possible to animate Flexbox inserts & removes?

I’ve fixed up @skyline3000’s demo based on this example from Treehouse. Not sure if this will break again if browsers change but this seems to be the intended way to animate flex size changes: http://jsfiddle.net/2gbPg/2/ Also I used jQuery but it technically isn’t required. .flexed { background: grey; /* The border seems to cause drawing …

Read more

Set min-width either by content or 200px (whichever is greater) together with max-width

The problem is that flex: 1 sets flex-basis: 0. Instead, you need .container .box { min-width: 200px; max-width: 400px; flex-basis: auto; /* default value */ flex-grow: 1; } .container { display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap; } .container .box { -webkit-flex-grow: 1; flex-grow: 1; min-width: 100px; max-width: 400px; height: 200px; background-color: #fafa00; overflow: …

Read more