Flexbox
≈ 2 min read
Names in other languages
No names in other languages are held for this entry yet.
Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.
CSS Flexible Box Layout, commonly known as Flexbox, is a CSS web layout model. It is in the W3C's candidate recommendation (CR) stage. The flex layout allows responsive elements within a container to be automatically arranged depending on viewport (device screen) size.
CSS Flexible Box Layout, commonly known as Flexbox, is a CSS web layout model. It is in the W3C's candidate recommendation (CR) stage. The flex layout allows responsive elements within a container to be automatically arranged depending on viewport (device screen) size.
Terminology
The following terms are associated with the flexbox layout model. Flex container Parent element that holds all flex items. Using the CSS display property, the container can be defined as either flex or inline-flex. Flex item Any direct child element held within the flex container is considered a flex item. Any text within the container element is wrapped in an unknown flex item. Axes Each flex box contains two axes: the main and cross axes. The main axis is the axis on which the items align with each other. The cross axis is perpendicular to the main axis. Flex-direction Establishes main axis. Possible arguments: row (default), row-reverse, column, column-reverse. Justify-content Determines how content gets placed on the main axis on the current line. Optional arguments: left, right, center, space-between, space-around. Align-items Determines the default for how flex items get placed on the cross axis on each line. Align-content Determines the default for how cross axis lines are aligned. Align-self Determines how a single item is placed along the cross axis. This overrides any defaults set by align-items. display: flex; Or: display: inline-flex; By setting the display to one of the two values above, an element becomes a flex container and its children, flex items. Setting the display to flex makes the container a block-level element, while setting the display to inline-flex makes the container an inline-level element. One of flexbox's advantages is the ability to easily align items within the container to the center of a page, both vertically and horizontally. .container { display: flex; align-items: center; justify-content: center; }
References
Text derived from https://en.wikipedia.org/w/index.php?oldid=1378909525 under CC BY-SA 4.0; modifications have been made.