0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-11-29 11:24:18 +01:00
Bootstrap/docs/layout/utilities-for-layout.md

32 lines
1.9 KiB
Markdown
Raw Normal View History

---
layout: docs
title: Utilities for layout
description: Use any of our dozens of responsive utility classes for showing, hiding, aligning, and spacing content.
group: layout
---
For faster mobile-friendly and responsive development, Bootstrap includes dozens of utility classes for showing, hiding, aligning, and spacing content. Below is a primer on what's included in Bootstrap and how these utilities can help you with layout.
## Contents
* Will be replaced with the ToC, excluding the "Contents" header
{:toc}
## Changing `display`
2017-03-05 20:03:35 +01:00
Use our `display` utilities for responsively toggling common values of the `display` property. Mix it with our grid system, content, or components to show or hide them across specific viewports.
## Flexbox options
2017-03-05 20:03:35 +01:00
Bootstrap 4 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 [our components](/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 our extra [flexbox utilities](/utilities/flexbox/) for sizing, alignment, spacing, and more.
## Margin and padding
2017-03-05 20:03:35 +01:00
Use the `margin` and `padding` [spacing utilities](/utilities/spacing/) to control how elements and components are spaced and sized. Bootstrap 4 includes a five-level scale for spacing utilities, based on a `1rem` value default `$spacer` variable. Choose values for all viewports (e.g., `.mr-3` for `margin-right: 1rem`), or pick responsive variants to target specific viewports (e.g., `.mr-md-3` for `margin-right: 1rem` starting at the `md` breakpoint).
## Toggle `visibility`
2017-03-05 20:03:35 +01:00
When toggling `display` isn't needed, you can toggle the `visibility` of an element with our [visibility utilities](/utilities/visibility/).