Skip to content

Instantly share code, notes, and snippets.

@himalay
Last active January 30, 2020 07:10
Show Gist options
  • Select an option

  • Save himalay/7b0cc096f3644aa86c0d89057e798d4d to your computer and use it in GitHub Desktop.

Select an option

Save himalay/7b0cc096f3644aa86c0d89057e798d4d to your computer and use it in GitHub Desktop.
BEM CSS
/*-------------------------------------
BEM (Block Element Modifier)
-------------------------------------*/
/*
<a href="http://css-tricks.com" class="btn btn--green btn--big">
<span class="btn__price">$9</span>
<span class="btn__text">Big button</span>
</a>
*/
/* Block */
.btn {
text-decoration: none;
background-color: white;
color: #888;
border-radius: 5px;
display: inline-block;
margin: 10px;
font-size: 18px;
text-transform: uppercase;
font-weight: 600;
padding: 10px 5px;
}
/* Element */
.btn__price {
background-color: white;
color: #fff;
padding-right: 12px;
padding-left: 12px;
margin-right: -10px; /* realign button text padding */
font-weight: 600;
background-color: #333;
opacity: .4;
border-radius: 5px 0 0 5px;
}
/* Element */
.btn__text {
padding: 0 10px;
border-radius: 0 5px 5px 0;
}
/* Modifier */
.btn--big {
font-size: 28px;
padding: 10px;
font-weight: 400;
}
/* Modifier */
.btn--green {
border-color: #3D9970;
color: white;
background-color: #3D9970;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment