HTML CSS Bootstrap JavaScript jQuery MySQL PHP Data Mining

Bootstrap Flex Direction

Once you initialize a container with .d-flex, the browser immediately establishes a layout "axis". By default, Bootstrap assumes you want a horizontal row. However, using flex-direction utilities, you can explicitly force the axis to become a vertical column or even reverse the flow entirely.


Horizontal Rows (.flex-row)

The standard behavior of Flexbox is to lay children out horizontally from left to right. This is achieved using the .flex-row class (which is technically applied by default when you use .d-flex, so you only need to explicitly write .flex-row if you are overriding a responsive breakpoint).

However, you can magically flip the visual order of elements from right to left by using the powerful .flex-row-reverse class!

1. Standard Row (.flex-row)
Element 1
Element 2
Element 3
2. Reversed Row (.flex-row-reverse)

Notice how "Element 1" is now physically pushed all the way to the far right edge!

Element 1
Element 2
Element 3
<!-- Standard horizontal layout (1, 2, 3) -->
<div class="d-flex flex-row">
    <div>1</div>
    <div>2</div>
    <div>3</div>
</div>

<!-- Reversed horizontal layout! Flows Right to Left! (3, 2, 1) -->
<div class="d-flex flex-row-reverse">
    <div>1</div>
    <div>2</div>
    <div>3</div>
</div>

Vertical Columns (.flex-column)

Using Flexbox doesn't always mean horizontal grids! Sometimes you need the powerful alignment tools of Flexbox (like centering or stretching) on a vertically stacked menu.

To rotate the Flexbox layout axis from horizontal to vertical, apply the .flex-column utility. Just like the row trick above, you can also flip the stack upside down using .flex-column-reverse!

1. Standard Column (.flex-column)
Top Article 1
Middle Article 2
Bottom Article 3
2. Upside Down! (.flex-column-reverse)
Top Article 1
Middle Article 2
Bottom Article 3
<!-- Forces Flexbox items into a vertical top-to-bottom stack -->
<div class="d-flex flex-column">
    <div>Article 1</div>
    <div>Article 2</div>
    <div>Article 3</div>
</div>

<!-- Stacks items vertically from bottom-to-top! -->
<div class="d-flex flex-column-reverse">
    <div>Article 1</div>
    ...
</div>