Codebase 3.0.1
Main Menu  

Flexbox

In Codebase, .flexbox is used for positioning and stretching items relative to their container.

Codebase has no old-fashioned grid system using flexbox or floats. If you want a real grid system, then use the Codebase CSS grid.

The Flexbox Wrapper

.flexbox

If you only use the class .flexbox, you get a flexbox with (immediate-child) flex-items.

One
Two
Three
Four
<div class="flexbox">
  <div>One</div>
  <div>Two</div>
  <div>Three</div>
  <div>Four</div>
</div>

Notes:

  1. There is no .flexbox-item class – there is no need for it.
  2. If necessary, flex items will wrap to form multiple rows.

Flexbox Stretching

.flexbox-grow-equal

Expands flex-items to occupy equal widths in the available space.

One
Two
Three
Four
<div class="flexbox flexbox-grow-equal">
  <div>One</div>
  <div>Two</div>
  <div>Three</div>
  <div>Four</div>
</div>

.flexbox-grow-auto

Expands flex-item widths adjusted according to their content.

Also, flexbox row wrapping is exemplified below.

This is the first flex-item
Another flex-item
Third
This is the last flex-item in this flexbox set

Flexbox Spacing

.flexbox.flexbox-gap

Adds a 0.75rem margin around each grid item on all four sides – so that a 1.5rem (i.e. default line height) gap is built in between grid items horizontally and vertically.

The .flexbox-gap class also adds a -0.75rem margin to the container in order to compensate for flex item margins towards the edges of the container.

Also, flexbox row wrapping is exemplified below.

Item
Item
Item
Item
Item
Item
Item
Item
Item
Item
Item
Item

.flexbox.flexbox-space-between

Item
Item
Item
Item
Item

Flexbox Positioning

.flexbox.flexbox-left / .flexbox.flexbox-center / .flexbox.flexbox-right

Left 1
Left 2
Left 3
Center 1
Center 2
Center 3
Right 1
Right 2
Right 3

.flexbox.flexbox-top / .flexbox.flexbox-middle / .flexbox.flexbox-bottom

Top 1
Top 2
Top 3
Middle 1
Middle 2
Middle 3
Bottom 1
Bottom 2
Bottom 3

Responsive Flexbox

Wrapper: .flexbox-md or .flexbox-lg
Wrapper modifiers: .flexbox-md-* or .flexbox-lg-*

Do you want a stack (column) of blocks to switch to a flexbox row aove a certain viewport width? Don't use .flexbox – use .flexbox-md or .flexbox-lg instead.

Example .flexbox-lg:

One
Two
Three
Four

Do you want your group of flex items to be stretched or positioned differently above a certain viewport width? Use .flexbox-md-* and/or .flexbox-lg-* modifiers.

Example .flexbox.flexbox-left.flexbox-md-center.flexbox-lg-right:

One
Two
Three
Four

Note: flexbox wrapper modifiers targeting a wider viewport width won’t work unless you have set a flexbox wrapper targeting the same or narrower viewport width.

E.g. This won’t be centered on medium viewports (but it is centered on large viewports):

<div class="flexbox-lg flexbox-md-center">
  <div>...</div>
  <div>...</div>
  <div>...</div>
</div>
Tip: Codebase flexbox layout classes play well with Codebase menus to create menubars.

Flexbox Classes

Wrapper Class Wrapper Modifier Class
.flexbox

Stretching:
.flexbox-grow-equal .flexbox-grow-auto

Spacing:
.flexbox-gap .flexbox-space-between

Horizontal positioning:
.flexbox-left .flexbox-center .flexbox-right

Vertical positioning:
.flexbox-top .flexbox-middle .flexbox-bottom

.flexbox-md

Stretching:
.flexbox-md-grow-equal .flexbox-md-grow-auto

Spacing:
.flexbox-md-gap .flexbox-md-space-between

Horizontal positioning:
.flexbox-md-left .flexbox-md-center .flexbox-md-right

Vertical positioning:
.flexbox-md-top .flexbox-md-middle .flexbox-md-bottom

.flexbox-lg

Stretching:
.flexbox-lg-grow-equal .flexbox-lg-grow-auto

Spacing:
.flexbox-lg-gap .flexbox-lg-space-between

Horizontal positioning:
.flexbox-lg-left .flexbox-lg-center .flexbox-lg-right

Vertical positioning:
.flexbox-lg-top .flexbox-lg-middle .flexbox-lg-bottom


Width: [-sm][-md → -lg][-lg]