Skip to content

Instantly share code, notes, and snippets.

@tomblanchard
Created September 11, 2014 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomblanchard/dc05f4c5f28f8766b5fc to your computer and use it in GitHub Desktop.
Save tomblanchard/dc05f4c5f28f8766b5fc to your computer and use it in GitHub Desktop.

Main Title

I have a utility class such as:

.mb {
  margin-bottom: 20px;
}

If element doesn't have bespoke styles

If the element which needs the utility class doesn't have any bespoke CSS styles attached to it just use the regular HTML class.

<div class="mb">
  ...
</div>

If element has bespoke styles

If the element is already targeted by CSS, then @extend the utility class to the elements class name/selector.

.post {
  background-color: #CCC;
  font-size: 2em;
  @extend .mb;
}
<div class="post">
  ...
</div>

Combination

Use both?

<div class="post mb">
  ...
</div>

Which is the best?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment