The CSS flexible box layout module defines a CSS box model optimized for user interface design, and the layout of items in one dimension. In the flex layout model, the children of a flex container can be laid out in any direction, and can "flex" their sizes, either growing to fill unused space or shrinking to avoid overflowing the parent. Both horizontal and vertical alignment of the children can be easily manipulated.
Flexible box layout in actionIn the following example, a container has been set to display: flex
, which means that the three child items become flex items. The value of justify-content
has been set to space-between
in order to space the items out evenly on the main axis. An equal amount of space is placed between each item with the left and right items being flush with the edges of the flex container. You can also see that the items are stretching on the cross axis, due to the default value of align-items
being stretch
. The items stretch to the height of the flex container, making them each appear as tall as the tallest item.
<div class="box">
<div>One</div>
<div>Two</div>
<div>Three <br />has <br />extra <br />text</div>
</div>
body {
font-family: sans-serif;
}
.box {
border: 2px dotted rgb(96 139 168);
display: flex;
justify-content: space-between;
}
.box > * {
border: 2px solid rgb(96 139 168);
border-radius: 5px;
background-color: rgb(96 139 168 / 0.2);
padding: 1em;
}
Reference Properties Glossary terms Guides
An overview of the features of Flexbox.
How Flexbox relates to other layout methods and other CSS specifications.
How the box alignment properties work with Flexbox.
Explaining the different ways to change the order and direction of items, and covering the potential issues in doing so.
Explaining the flex-grow, flex-shrink and flex-basis properties.
How to create flex containers with multiple lines and control the display of the items in those lines.
Common design patterns that are typical Flexbox use cases.
Learn how to use flexbox layout to create web layouts.
Details features of CSS box alignment which are specific to flexbox.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.3