Skip to main content

Layout

Utilities for layout

For faster mobile-friendly and responsive development, felt-css includes dozens of utility classes for showing, hiding, aligning, and spacing content.

View page source on GitHub

Changing display#

Use the display utilities for responsively toggling common values of the display property. Mix them with the grid system, content, or components to show or hide them across specific viewports.

Shown below the lg breakpoint
Shown from the lg breakpoint up
<div class="d-lg-none p-2 bg-body-tertiary">Shown below the <code>lg</code> breakpoint</div>
<div class="d-none d-lg-block p-2 bg-body-tertiary">Shown from the <code>lg</code> breakpoint up</div>

Flexbox options#

felt-css is built with flexbox, but not every element's display has been changed to display: flex as this would add many unnecessary overrides and unexpectedly change key browser behaviors. Most of the components are built with flexbox enabled.

Should you need to add display: flex to an element, do so with .d-flex or one of the responsive variants (e.g., .d-sm-flex). You'll need this class or display value to allow the use of the extra flexbox utilities for sizing, alignment, spacing, and more.

A column on phones
a row from sm up
<div class="d-flex flex-column flex-sm-row gap-2">
  <div class="p-2 bg-body-tertiary flex-sm-fill">A column on phones</div>
  <div class="p-2 bg-body-tertiary flex-sm-fill">a row from <code>sm</code> up</div>
</div>

Margin and padding#

Use the margin and padding spacing utilities to control how elements and components are spaced and sized. felt-css includes a six-level scale for spacing utilities (0 to 5), the same as Bootstrap's: .25rem, .5rem, 1rem, 1.5rem and 3rem, also available as --felt-space-1 to --felt-space-5. Choose values for all viewports (e.g., .me-3 for margin-right: 1rem in LTR), or pick responsive variants to target specific viewports (e.g., .me-md-3 for margin-right: 1rem —in LTR— starting at the md breakpoint).

Toggle visibility#

When toggling display isn't needed, you can toggle the visibility of an element with the visibility utilities. Invisible elements will still affect the layout of the page, but are visually hidden from visitors.