Chapter 3. Flex Items

In the previous chapters, we learned how to globally lay out all the flex items within a flex container by adding flexbox property values to that container. The flexible box layout specification provides several additional properties applicable directly to flex items. With these flex item–specific properties, we can more precisely control the layout of individual flex containers’ non-anonymous flex items.

Items with display: flex; become flex containers, and their non-absolutely positioned children become flex items
Figure 3-1. Items with display: flex; become flex containers, and their non-absolutely positioned children become flex items

Now that we have a good understanding of the properties applicable to the flex container, it’s time to focus on properties applicable to the flex items.

What Are Flex Items?

We create flex containers simply by adding a display: flex or display: inline-flex to an element that has child nodes. The children of those flex container are called flex items, be they DOM nodes, nonempty text nodes, or generated content.

When it comes to text-node children of flex containers, if the text node is not empty (containing content other than whitespace) it will be wrapped in an anonymous flex item, behaving like its flex item siblings. While these anonymous flex items do inherit all the flex properties set by the flex container, just like their DOM ...

Get Flexbox in CSS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.