Sizing utilities

Responsive utility classes which can be used to set the width and height of elements.

Relative to the parent #

The width of an element can be set relative to the parent using the following classes:

  • .w-{value}
  • .w-{breakpoint}-{value}

The height of an element can be set relative to the parent using the following classes:

  • .h-{value}
  • .h-{breakpoint}-{value}

The {breakpoint} can be sm, md, lg, xl, or xxl. If the breakpoint is not provided, the element will be affected on all screen sizes (including on extra small screens). On the other hand, if it is provided, the element will be affected only for that breakpoint and up.

The {value} can be one of the following:

{value} Description
25 Sets width and height to 25%
50 Sets width and height to 50%
75 Sets width and height to 75%
100 Sets width and height to 100%
auto Sets width and height to auto

These classes are shown in action in the examples below.

.w-25
.w-50
.w-75
.w-100
.w-auto
HTML
<!-- Width 25% -->
<div class="w-25">
  ...
</div>

<!-- Width 50% -->
<div class="w-50">
  ...
</div>

<!-- Width 75% -->
<div class="w-75">
  ...
</div>

<!-- Width 100% -->
<div class="w-100">
  ...
</div>

<!-- Width auto -->
<div class="w-auto">
  ...
</div>
.h-25
.h-50
.h-75
.h-100
.h-auto
HTML
<!-- Height 25% -->
<div class="h-25">
  ...
</div>

<!-- Height 50% -->
<div class="h-50">
  ...
</div>

<!-- Height 75% -->
<div class="h-75">
  ...
</div>

<!-- Height 100% -->
<div class="h-100">
  ...
</div>

<!-- Height auto -->
<div class="h-auto">
  ...
</div>

Max width and height #

The max-width and max-height of an element can be set to 100% using the following classes:

  • mw-100 / mw-{breakpoint}-100 — sets max-width: 100%
  • mh-100 / mh-{breakpoint}-100 — sets max-height: 100%

Relative to the viewport #

The following classes are also available for setting the width and height of an element relative to the viewport (as opposed to the parent):

  • min-vw-100 / min-vw-{breakpoint}-100 — sets min-width: 100vw
  • min-vh-100 / min-vh-{breakpoint}-100 — sets min-height: 100vh
  • vw-100 / vw-{breakpoint}-100 — sets width: 100vw
  • vh-100 / vh-{breakpoint}-100 — sets height: 100vh

Specific width and height #

The width of an element can be set to a specific size using the following classes:

  • .specific-w-{value}
  • .specific-w-{breakpoint}-{size}

The height of an element can be set to a specific size using the following classes:

  • .specific-h-{value}
  • .specific-h-{breakpoint}-{size}

The {size} can be one of the following:

{value} Description
25 Sets width and height to 1.5625rem / 25px
50 Sets width and height to 3.125rem / 50px
75 Sets width and height to 4.6875rem / 75px
100 Sets width and height to 6.25rem / 100px
150 Sets width and height to 9.375rem / 150px
200 Sets width and height to 12.5rem / 200px
250 Sets width and height to 15.625rem / 250px
300 Sets width and height to 18.75rem / 300px
350 Sets width and height to 21.875rem / 350px
400 Sets width and height to 25rem / 400px
450 Sets width and height to 28.125rem / 450px
500 Sets width and height to 31.25rem / 500px
550 Sets width and height to 34.375rem / 550px
600 Sets width and height to 37.5rem / 600px

These classes can be used to set the sizes of elements to very specific values, and as a result, they can come in handy in quite a few common scenarios.

150 × 100
HTML
<!-- Specific width and height -->
<div class="specific-w-150 specific-h-100">
  150 × 100
</div>
Up next
Spacing utilities

Help us grow

Our main goal is to make Halfmoon the go-to framework for building websites, dashboards and tools. If you believe in our mission, consider becoming a sponsor and help us grow.

You can email us directly if you have any queries. We are always happy to answer.

Subscribe for updates

We will notify you when the framework gets a substantial update. No spam ever.

Follow us on Twitter so that you can stay updated that way.