Vertical Spacers

Add global top and bottom padding at a variety of sizes which adjust to breakpoints automatically.

Available options are any combination of .spacer-top- or .spacer-btm- with any of the available sizes: none, small, medium, or large. For example, .spacer-top-small or .spacer-btm-large.

Breakpoint suffixes for spacer classes are also available (e.g. .spacer-btm-medium@md)

none small medium large
xs 0 24 36 48
sm 0 40 64
md 0 32 48 80

Media Object

An object (like an image) and content to the right or left. Source

To place the object to the left, use .pull-left on the media-object, or right using .pull-right.

The element with the float on it does not have to be an anchor tag.

Heads up! max-width: 100%; does not constrain the image. Hi resolution images may grow larger than you expect. To avoid this, set a width on the image.

Generic placeholder image

Media heading

Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.

Generic placeholder image

Media heading

Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.

Generic placeholder image

Nested media heading

Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.

Generic placeholder image

Media heading, image pull-right

Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.

Markup

<div class="media">
  <a class="pull-left" href="#">
    <img class="media-object" src="https://placehold.it/64x64" alt="Generic placeholder image">
  </a>
  <div class="media__body">
    <h4 class="media__heading">Media heading</h4>
    <p>Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo.</p>
  </div>
</div>

Flag Object

An object (like an image) and content to the right or left. Source

Heads up! For this method to work, the image cannot have max-width: 100%; so it is set to none. Hi resolution images may grow larger than you expect. To avoid this, set a width on the image.

Pellentesque habitant.

Top aligned. Pellentesque habitant.

Bottom aligned. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra.

Markup

<div class="flag flag--bottom">
  <div class="flag__image">
    <img src="https://placehold.it/120/222626">
  </div>
  <div class="flag__body">
    <p>Bottom aligned. Pellentesque habitant...</p>
  </div>
</div>

Vertical Centering

Use flexbox and the .flex-center class.

I’m centered.

Markup

<div style="height:200px;" class="flex-center justify-content-center docs-dark-block">
  <p class="docs-type-body-3 marginless">I’m centered.</p>
</div>

Fill Parent

Use .fill-parent to set position: absolute;, with top, left, right, and bottom values all set to 0 so that it fills its containing block.

Heads up! The parent element needs to be position:relative;

I fill the containing block.

Markup

<div class="relative" style="height:200px; width:100%; background:green;">
  <div class="fill-parent" style="background:gray;">I fill the containing block.</div>
</div>

Aspect Boxes

Maintain an aspect ratio with padding-bottom.

Aspect boxes are most useful for holding images and other content which loads later. This way when the image loads, it does not change the layout of the page.

Available ratios are .aspect-- with any of the available sizes: 16x9, 4x3, 3x2, 3x1, 2x3, 2x1, or 1x1 as well as none. For example, .aspect--16x9 or .aspect--2x1@sm.

16x9
4x3
3x2
3x1
2x3
2x1
1x1
aspect--2x1 aspect--none@sm
aspect--2x1 aspect--none@xs
aspect--16x9@xs aspect--2x1@sm

Helper Classes

Great for Composibility.

Use these classes to avoid creating a new single CSS rule which would do the exact same thing.

.relative { position: relative; }
.static { position: static; }
.ib { display: inline-block; }
.block { display: block; }
.flex { display: flex; }

.pull-left { float: left; }
.pull-right { float: right; }

.marginless { margin: 0 !important; }
.paddingless { padding: 0 !important; }

.no-transition { transition: none !important; }
.no-transition-duration { transition-duration: 0ms !important; }

.height-inherit { height: inherit; }
.height-full { height: 100%; }
.no-min-height { min-height: 0; }

.width-inherit { width: inherit; }
.width-full { width: 100%; }
.no-min-width { min-width: 0; }

.grab { cursor: grab; }

.grab.grabbing,
.grabbing,
.grabbing .grab {
  cursor: grabbing;
}

.unselectable {
  user-select: none;
}

.flex-center {
  display: flex;
  align-items: center;
  height: 100%;
}

.align-items-center { align-items: center; }
.justify-content-center { justify-content: center; }

.clearfix { @include clearfix(); }
.fill-parent { @include fill-parent(); }

.fade {
  opacity: 0;
  transition: opacity .15s linear;

  &.in {
    opacity: 1;
  }
}

.background-image-cover {
  @include fill-parent();
  @include background-cover();
  width: 100%;
  height: 100%;
}

// Overflow hidden because polyfills will resize the image within.
.image-cover { overflow: hidden; }
.image-cover img {
  width: 100%;
  max-width: none;
  height: 100%;
  object-fit: cover;
}

// Place on an element (like the body) to prevent the mouse from scrolling it.
// This does not work for touch devices.
.no-overflow,
.no-scroll {
  overflow: hidden;
}

.off-screen {
  position: absolute !important;
  left: -9999px !important;
}

// Hide from both screenreaders and browsers: h5bp.com/u
.hidden {
  display: none !important;
  visibility: hidden;
}

// Hide only visually, but have it available for screenreaders: h5bp.com/v
.visuallyhidden {
  border: 0;
  clip: rect(0 0 0 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
}

// Hide visually and from screenreaders, but maintain layout
.invisible {
  visibility: hidden;
}

.unstyled-list {
  list-style-type: none;
  padding: 0;
  margin: 0;
}

.unstyled-button {
  padding: 0;
  background: none;
  border: 0;
}