An official website of the United States government
Official websites use .gov A .gov website belongs to an official government organization in the United States.
Secure .gov websites use HTTPS A lock or https:// means you’ve safely connected to the .gov website. Share sensitive information only on official, secure websites.
Use the flexbox utility classes to control various flexbox properties. These are especially useful when combined with flexbox grid classes.
For these utility classes to work, first create a flex container — you can use the .ds-u-display--flex utility class — then apply these utility classes to the container's direct children elements.
Flex direction
Use the flex-direction utility class on a flexbox container to change the alignment of its child elements on the main axis (x-axis by default).
The CSS flex-direction property defines how the browser distributes space between and around content items along the main axis of their container. — MDN
<section><divclass="ds-u-margin-bottom--2"><codeclass="ds-u-margin-bottom--1">.ds-u-flex-direction--row</code><articleclass="ds-u-display--flex ds-u-flex-direction--row ds-u-padding--1 ds-u-border--1"><divclass="utility-example ds-u-padding--1 ds-u-margin--1"style="width: 50%">
Element #1
</div><divclass="utility-example ds-u-padding--1 ds-u-margin--1"style="width: 50%">
Element #2
</div><divclass="utility-example ds-u-padding--1 ds-u-margin--1"style="width: 50%">
Element #3
</div></article></div><divclass="ds-u-margin-bottom--2"><codeclass="ds-u-margin-bottom--1">.ds-u-flex-direction--column</code><articleclass="ds-u-display--flex ds-u-flex-direction--column ds-u-padding--1 ds-u-border--1"><divclass="utility-example ds-u-padding--1 ds-u-margin--1"style="width: 50%">
Element #1
</div><divclass="utility-example ds-u-padding--1 ds-u-margin--1"style="width: 50%">
Element #2
</div><divclass="utility-example ds-u-padding--1 ds-u-margin--1"style="width: 50%">
Element #3
</div></article></div><divclass="ds-u-margin-bottom--2"><codeclass="ds-u-margin-bottom--1">
.ds-u-flex-direction--row-reverse></code><articleclass="ds-u-display--flex ds-u-flex-direction--row-reverse ds-u-padding--1 ds-u-border--1"><divclass="utility-example ds-u-padding--1 ds-u-margin--1"style="width: 50%">
Element #1
</div><divclass="utility-example ds-u-padding--1 ds-u-margin--1"style="width: 50%">
Element #2
</div><divclass="utility-example ds-u-padding--1 ds-u-margin--1"style="width: 50%">
Element #3
</div></article></div><divclass="ds-u-margin-bottom--2"><codeclass="ds-u-margin-bottom--1">
.ds-u-flex-direction--column-reverse
</code><articleclass="ds-u-display--flex ds-u-flex-direction--column-reverse ds-u-padding--1 ds-u-border--1"><divclass="utility-example ds-u-padding--1 ds-u-margin--1"style="width: 50%">
Element #1
</div><divclass="utility-example ds-u-padding--1 ds-u-margin--1"style="width: 50%">
Element #2
</div><divclass="utility-example ds-u-padding--1 ds-u-margin--1"style="width: 50%">
Element #3
</div></article></div></section>
Justify content
Use the justify-content utility class on a flexbox container to change the alignment of its child elements on the main axis (x-axis by default).
The CSS justify-content property defines how the browser distributes space between and around content items along the main axis of their container. — MDN
Use the align-items utility class on a flexbox container to change the alignment of its child elements on the cross axis (y-axis by default).
The CSS align-items property defines how the browser distributes space between and around flex items along the cross-axis of their container. This means it works like justify-content but in the perpendicular direction. — MDN
Use the flex-wrap utility class on a flexbox container to change how its child elements wrap.
The CSS flex-wrap property specifies whether flex items are forced into a single line or can be wrapped onto multiple lines. If wrapping is allowed, this property also enables you to control the direction in which lines are stacked. — MDN