Images

Opt images into responsive behavior (so they never become wider than their parent) and add lightweight styles to them.

Responsive images #

Images can be made responsive with .img-fluid. This applies max-width: 100% and height: auto to the image so that it scales with the parent width.

Image
HTML
<!-- Responsive image -->
<div class="row">
  <div class="col-9 col-sm-6 col-md-5 mx-auto">
    <img src="..." class="img-fluid rounded" alt="...">
  </div>
</div>

Image thumbnails #

In addition to border utilities, you can use .img-thumbnail to give an image a rounded 1px border appearance.

Image
HTML
<!-- Image thumbnail -->
<img src="..." class="img-thumbnail rounded" alt="..." width="200">

Aligning images #

You can use spacing, flexbox, text alignment, or even float utilities to align images in different ways. Flexbox is arguably the best way to align and place images in useful ways.

Image
Image
HTML
<!-- Aligning images using flexbox -->
<div class="d-flex justify-content-between">
  <img src="..." class="rounded" alt="..." width="120">
  <img src="..." class="rounded" alt="..." width="120">
</div>

Given below is another example of centering an image using display and margin.

Image
HTML
<!-- Centering image using display and margin -->
<img src="..." class="d-block mx-auto rounded" alt="..." width="200">

Picture #

If you are using the <picture> element to specify multiple <source> elements for a specific <img>, make sure to add the .img-* classes to the <img> and not to the <picture> tag.

HTML
<picture>
  <source srcset="..." type="image/svg+xml">
  <img src="..." class="img-fluid img-thumbnail" alt="...">
</picture>
Up next
Tables

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.