BodinglesTM - -   Bright Lightbulb Graphic Ideas   - -

Full Stack MERN Web Development

Back to Bootstrap Index

Bootstrap Utilities




Bootstrap is controlled with inline styles. The style call is placed inside the controlling HTML tag. Bootstrap has Utilities for responsively toggling common values of the Display and Flexbox properties, Margins and Padding, and Visibility properties. More information about Bootstrap Utilities can be found here.





Bootstrap Utilities Demo

We set up the following box with background color-primary, text color-white, margin of 5px, and padding of 2px,
[ class="bg-primary text-white m-5 p-2" ]

Inline Element
Hidden on xs, Visible from md

We are going to change the first line to inline by changing the display property. We'll also change the background color to highlight the effect.
[ class="bg-warning d-inline" ]

Inline Element
Hidden on xs, Visible from md

Now we can hide the next line for all displays except medium size or larger, with the following, [ class="d-none d-md-block" ].
We are telling it to never display this line (d-none), then we block this rule if the user is using a medium size or larger display (d-md-block).
If you resize the screen, you'll see the effect.

Inline Element
Hidden on xs, Visible from md

Margins and Padding

Margins are controlled with the m tag, and padding is controlled with the p tag.

From this, we can add t(top), b(bottom), l(left), and r(right).

We can also add x to select the horizontal sides, and y to select the vertical sides.

Here we set "mb-2 p-3". We also added the border, so class="border mb-2 p-3"
Same as above but we added a larger padding of 5. class="border mb-2 p-5"
Here we set a top margin only, then a horizontal and vertical padding for the sides. class="border mt-3 px-5 py-1"

Back to Top