Bootstrap Sizing

Easily make an element as wide or as tall with our width and height utilities.

Bootstrap

Relative to the parent

Width and height utilities are generated from the utility API in _utilities.scss. Includes support for 25%, 50%, 75%, 100%, and auto by default. Modify those values as you need to generate different utilities here.

Width 25%
Width 50%
Width 75%
Width 100%
Width auto
<div class="w-25 p-3" style="background-color: #eee;">Width 25%</div>
<div class="w-50 p-3" style="background-color: #eee;">Width 50%</div>
<div class="w-75 p-3" style="background-color: #eee;">Width 75%</div>
<div class="w-100 p-3" style="background-color: #eee;">Width 100%</div>
<div class="w-auto p-3" style="background-color: #eee;">Width auto</div>
Height 25%
Height 50%
Height 75%
Height 100%
Height auto
<div style="height: 100px; background-color: rgba(255,0,0,0.1);">
<div class="h-25 d-inline-block" style="width: 120px; background-color: rgba(0,0,255,.1)">Height 25%</div>
<div class="h-50 d-inline-block" style="width: 120px; background-color: rgba(0,0,255,.1)">Height 50%</div>
<div class="h-75 d-inline-block" style="width: 120px; background-color: rgba(0,0,255,.1)">Height 75%</div>
<div class="h-100 d-inline-block" style="width: 120px; background-color: rgba(0,0,255,.1)">Height 100%</div>
<div class="h-auto d-inline-block" style="width: 120px; background-color: rgba(0,0,255,.1)">Height auto</div>
</div>

You can also use max-width: 100%; and max-height: 100%; utilities as needed.

Max-width 100%
<img src="..." class="mw-100" alt="...">
Max-height 100%
<div style="height: 100px; background-color: rgba(255,0,0,.1);">
<div class="mh-100" style="width: 100px; height: 200px; background-color: rgba(0,0,255,.1);">Max-height 100%</div>
</div>

Relative to the viewport

You can also use utilities to set the width and height relative to the viewport.

<div class="min-vw-100">Min-width 100vw</div>
<div class="min-vh-100">Min-height 100vh</div>
<div class="vw-100">Width 100vw</div>
<div class="vh-100">Height 100vh</div>

Torus Kit

Relative to parent

Responsive height

Unit-based

Set height of an element in rem unit by adding h-<size>rem class. Here is the list ov available classes:

  • .h-0rem
  • .h-5rem
  • .h-10rem
  • .h-15rem
  • .h-20rem
  • .h-25rem
  • .h-30rem
  • .h-35rem
  • .h-40rem
  • .h-45rem

To make it responsive, use h-<breakpoint>-<size> where breakpoint is one of sm, md, lg, xl or xxl.

In example below, the first two elements has fixed height 5rem and 10rem on all resolutions. However, the third element has 5rem height from xs resolution up, but from the md resolution, it has changed to 15rem.

.h-5rem
.h-10rem
.h-md-15rem .h-5rem
<div class="h-5rem">.h-5rem</div>
<div class="h-10rem">.h-10rem</div>
<div class="h-md-15rem h-5rem">.h-md-15rem .h-5rem</div>

You can add or remove the height values in _variables.scss. Here’s a default height list for the $height-rem:

$height-rem: (
  0rem,
  5rem,
  10rem,
  15rem,
  20rem,
  25rem,
  30rem,
  35rem,
  40rem,
  45rem,
  50rem,
);
Percent-based

Extended Bootstrap .h-<size> height utility, where <size> is in percents and is one of:

  • .h-10
  • .h-20
  • .h-25
  • .h-30
  • .h-33
  • .h-40
  • .h-50
  • .h-60
  • .h-66
  • .h-70
  • .h-75
  • .h-80
  • .h-90
  • .h-100
  • .h-auto

They are also responsive when using h-<breakpoint>-<size>.

.h-40
.h-25
.h-33 .h-md-75
<div style="height: 20rem;">
  <div class="h-40">.h-40</div>
  <div class="h-25">.h-25</div>
  <div class="h-33 h-md-75">.h-33 .h-md-75</div>
</div>

Responsive width

Extended Bootstrap .w-<size> percent-based width utility that includes:

  • .w-10
  • .w-20
  • .w-25
  • .w-30
  • .w-33
  • .w-40
  • .w-50
  • .w-60
  • .w-66
  • .w-70
  • .w-75
  • .w-80
  • .w-90
  • .w-100
  • .w-auto

They are also responsive when using .w-<breakpoint>-<size> utility class.

Width 25%
Width 50%
Width 75%
Width 100%
Width auto
Width 100% on SM and 66% on MD and up
<div class="w-25">Width 25%</div>
<div class="w-50">Width 50%</div>
<div class="w-75">Width 75%</div>
<div class="w-100">Width 100%</div>
<div class="w-auto">Width auto</div>
<div class="w-sm-100 w-md-66">Width 100% on SM and 66% on MD and up</div>

Relative to the viewport

You can also use utilities to set the width and height relative to the viewport.

Responsive height

<!-- Height: 100% of view viewport -->

<div class="vh-100">Height 100vh</div>
<div class="vh-sm-100">Height 100vh from SM and up</div>

<!-- Min height: 100% of view viewport -->

<div class="min-vh-100">Min-height 100vh</div>
<div class="min-vh-sm-100">Min-height 100vh on SM and up</div>

Responsive width

<!-- Width: 100% of view viewport -->

<div class="vw-100">Width 100vw</div>
<div class="vw-sm-100">Width 100vw from SM and up</div>

<!-- Min width: 100% of view viewport -->

<div class="min-vw-100">Min-width 100vw</div>
<div class="min-vw-sm-100">Min-width 100vw on SM and up</div>