BodinglesTM - -   Bright Lightbulb Graphic Ideas   - -

Full Stack MERN Web Development

Back to Bootstrap Index

Width and Height Utilities


Width and Height sizing utilities. More information can be found here.

In some examples below, we change the background color to highlight some of the different text
components. Background colors are covered more specifically in a later lesson..


Width Utilities

Width percent can be set using w and setting the width percentage. This is the percent of width based on the parent element.

*note: you do not use the percent sign %, just the number.

Width 25% | class="w-25"
Width 50% | class="w-50"
Width 75% | class="w-75"
Width 100% | class="w-100"
Width Auto | class="w-auto"

Because Bootstrap width and height is based on the parent size, if we change the size of the parent container, in this case a < div>, then the children will resize accordingly.

Lets change the parent width to 900px.

Width 25% | class="w-25"
Width 50% | class="w-50"
Width 75% | class="w-75"
Width 100% | class="w-100"
Width Auto | class="w-auto"

Remember, Bootstrap width and height is based on the parent size, if we change the size of the parent container, in this case a < div>, then the children will resize accordingly.

In the following, we'll set the parent height to 500px. We'll also make the elements display "inline by using the bootstrap class="d-inline-block".

Height Utilities

Height 25%
Height 50%
Height 75%
Height 100%
Height auto

Viewport Relative Sizes

We can replace width and height with vw (viewport width) and vh (viewport height).
What this means is the viewable area of the screen.

We set either min-vw or vw to set the minimum or maximum width of the view area, likewise,
we can set either min-vh or vh to set the minimum and maximum height of the view area.

class="min-vw-100" | Min-width 100vw
class="min-vh-100" | Min-height 100vh
class="vw-100" | Max-width 100vw
class="vh-100" | Max-height 100vh

Back to Top