Skip to content

Instantly share code, notes, and snippets.

@charliewilco
Created September 30, 2014 20:51
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 charliewilco/3d37ac291ef8a832d485 to your computer and use it in GitHub Desktop.
Save charliewilco/3d37ac291ef8a832d485 to your computer and use it in GitHub Desktop.
BEM example
<div class="block">
<div class="block--element">
<h3>Headline Level 3</h3>
<div class="block--element_modifier">
<p>Other stuff you might need to know</p>
</div>
</div>
<div class="block--element">
<h3>Headline Level 3</h3>
<div class="block--element_modifier">
<p>Other stuff you might need to know</p>
</div>
</div>
</div>
// ----
// Sass (v3.4.4)
// Compass (v1.0.1)
// ----
$mango: mix(gold, tomato, 100%);
$radius: .25rem;
.block {
font-family: Avenir;
background: $mango;
padding: .5rem;
max-width: 25rem;
border-radius: $radius;
color: goldenrod;
h3 {
font-weight: 300;
text-transform: uppercase;
}
&--element {
background: lighten($mango, 25%);
border-radius: $radius;
padding: .5rem;
margin-bottom: 2rem;
&:last-of-type { margin-bottom: 0; }
&_modifier {
border-top: 3px solid tomato;
}
}
}
.block {
font-family: Avenir;
background: gold;
padding: .5rem;
max-width: 25rem;
border-radius: 0.25rem;
color: goldenrod;
}
.block h3 {
font-weight: 300;
text-transform: uppercase;
}
.block--element {
background: #ffeb80;
border-radius: 0.25rem;
padding: .5rem;
margin-bottom: 2rem;
}
.block--element:last-of-type {
margin-bottom: 0;
}
.block--element_modifier {
border-top: 3px solid tomato;
}
<div class="block">
<div class="block--element">
<h3>Headline Level 3</h3>
<div class="block--element_modifier">
<p>Other stuff you might need to know</p>
</div>
</div>
<div class="block--element">
<h3>Headline Level 3</h3>
<div class="block--element_modifier">
<p>Other stuff you might need to know</p>
</div>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment