

Since flexbox is a whole module and not a single property, it involves a lot of things including its whole set of properties. Note: Flexbox layout is most appropriate to the components of an application, and small-scale layouts, while the Grid layout is intended for larger scale layouts. While those work well for pages, they lack flexibility (no pun intended) to support large or complex applications (especially when it comes to orientation changing, resizing, stretching, shrinking, etc.). Most importantly, the flexbox layout is direction-agnostic as opposed to the regular layouts (block which is vertically-based and inline which is horizontally-based). A flex container expands items to fill available free space or shrinks them to prevent overflow. The main idea behind the flex layout is to give the container the ability to alter its items’ width/height (and order) to best fill the available space (mostly to accommodate to all kind of display devices and screen sizes).

Hence, the text in the li is a flex item.The Flexbox Layout (Flexible Box) module ( a W3C Candidate Recommendation as of October 2017) aims at providing a more efficient way to lay out, align and distribute space among items in a container, even when their size is unknown and/or dynamic (thus the word “flex”).

The flexbox specification provides for similar behavior.Įach in-flow child of a flex container becomes a flex item, and eachĬontiguous run of text that is directly contained inside a flexĬontainer is wrapped in an anonymous flex item. Must be treated as an anonymous inline element. This makes it an anonymous inline element and child of the parent.Īny text that is directly contained inside a block container element The reason is that text that is not explicitly wrapped by an inline-level element is algorithmically wrapped by an inline box. Some people may be wondering how a run of text. However, one item must be pinned to the top, so it is set to align-self: flex-start. Therefore, align-items: center means all flex items will be set to align-self: center.īut you can override this default by adjusting the align-self on individual items.įor example, you may want equal height columns, so the container is set to align-items: stretch. The align-items property (on the container) sets the default value of align-self (on the items). Technically, here's how align-items and align-self work.
