Bootstrap Tutorial

BS4 HomeBS4 Container

BS4 Borders

BS4 Border AdditiveBS4 Border SubtractiveBS4 Border ColorBS4 Border Radius

BS4 Float

BS4 floatBS4 clearfix

BS4 Close icon

BS4 Close Icon

BS4 Colors

BS4 ColorBS4 Background color

BS4 Display

BS4 Display NotationBS4 Display in Print

BS4 Embed

BS4 embed

BS4 Flex

BS4 FlexBS4 Flex DirectionBS4 justify-contentBS4 align-itemsBS4 align-selfBS4 align-contentBS4 Flex GrowBS4 Flex ShrinkBS4 Flex FillBS4 Flex WrapBS4 OrderBS4 Auto Margins

BS4 Sizing

BS4 WidthBS4 Height

BS4 Spacing

BS4 MarginBS4 PaddingBS4 Horizontal centering

BS4 Text

BS4 Text alignmentBS4 Text wrappingBS4 Text transformBS4 Font weight and italicsBS4 Text decorationBS4 Text resetBS4 Text monospace

BS4 Alignment

BS4 Vertical alignment

BS4 Visibility

BS4 Visibility

BS4 Overflow

BS4 Overflow

BS4 Link

BS4 Stretched Link

BS4 Shadow

BS4 Shadow

BS4 Position

BS4 Position

BS4 Typography

BS4 Typography HeadingsBS4 Typography Custom HeadingsBS4 Typography Display HeadingsBS4 Typography LeadBS4 Typography Inline textBS4 Typography AbbreviationsBS4 Typography BlockquotesBS4 Typography List UnstyledBS4 Typography List Inline

BS4 Code

BS4 Code InlineBS4 Code BlocksBS4 Code VariablesBS4 Sample OutputBS4 User input

BS4 Image

BS4 Image ResponsiveBS4 Image Thumbnails

BS4 Figures

BS4 Figure

BS4 Grid

BS4 Grid

BS4 Media Object

BS4 Media Object

BS4 Table

BS4 TableBS4 Table HeadBS4 Table CaptionsBS4 Table Responsive

BS4 Components

BS4 AlertBS4 BadgeBS4 BreadcrumbBS4 ButtonBS4 Button GroupBS4 CardBS4 CarouselBS4 CollapseBS4 DropdownBS4 FormBS4 Input GroupBS4 JumbotronBS4 List GroupBS4 ModalBS4 NavsBS4 NavbarBS4 PaginationBS4 PopoversBS4 ProgressBS4 SpinnersBS4 TooltipsBS4 ToastsBS4 Scrollspy

Bootstrap4 Flex Direction

Last Updated:

Bootstrap4 Flex Direction

Bootstrap4 Flex Direction utility classes will set the direction of flex items in a flex container with direction utilities. In most cases you can omit the horizontal class here as the browser default is row.

Bootstrap4 Flex Direction Row

In the following example, we will set the direction of the flex items to row and row reverse using the classes .flex-row and .flex-row-reverse.

Example

HTML Online Editor
<!DOCTYPE html> <html lang="en-US"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script> </head> <body> <h1>Direction Row</h1> <div class="d-flex flex-row mb-3"> <div class="p-2">Flex item 1</div> <div class="p-2">Flex item 2</div> <div class="p-2">Flex item 3</div> </div> <div class="d-flex flex-row-reverse"> <div class="p-2">Flex item 1</div> <div class="p-2">Flex item 2</div> <div class="p-2">Flex item 3</div> </div> </body> </html>

Classes

The following table provides a list of all classes to set the direction of the flex items.

Note: All the odd rows in the table has {sm|md|lg|xl} which means it sets the direction of the flex items only at specific viewport. For example, .flex-md-row-reverse will set a row in reverse direction only when the width of the viewport is ≥768px.

viewport: sm (≥576px), md (≥768px), lg (≥992px), and xl (≥1200px)

Class Explanation
.flex-row Display flex items left-aligned and horizontally.
.flex-{sm|md|lg|xl}-row Display flex items left-aligned and horizontally in specific viewport.
.flex-row-reverse Display flex items right-aligned and horizontally.
.flex-{sm|md|lg|xl}-row-reverse Display flex items right-aligned and horizontally in specific viewport.
.flex-column Display flex items top-aligned and vertically.
.flex-{sm|md|lg|xl}-column Display flex items top-aligned and vertically in specific viewport.
.flex-column-reverse Display flex items bottom-aligned and vertically.
.flex-{sm|md|lg|xl}-column-reverse Display flex items bottom-aligned and vertically in specific viewport.

Bootstrap4 Flex Direction Column

In the following example, we will set the direction of the flex items to column and column reverse using the classes .flex-column and .flex-column-reverse.

Example

HTML Online Editor
<!DOCTYPE html> <html lang="en-US"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script> </head> <body> <h1>Column</h1> <h1>Flex Direction Column</h1> <div class="d-flex flex-column mb-3"> <div class="p-2">Flex item 1</div> <div class="p-2">Flex item 2</div> <div class="p-2">Flex item 3</div> </div> <div class="d-flex flex-column-reverse"> <div class="p-2">Flex item 1</div> <div class="p-2">Flex item 2</div> <div class="p-2">Flex item 3</div> </div> </body> </html>

Share this Page

Meet the Author