Skip to content

Instantly share code, notes, and snippets.

@webuniverseio
Created August 17, 2014 13:46
Show Gist options
  • Save webuniverseio/9b515a8989b2c80a2bb0 to your computer and use it in GitHub Desktop.
Save webuniverseio/9b515a8989b2c80a2bb0 to your computer and use it in GitHub Desktop.
BEM (GRM) style modifiers
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<span class="a button a">WHOA</span>
<span class="a button--primary a">WHOA</span>
<span class="a button--primaryAlt a">WHOA</span>
<div class="widget">
<div class="widget-buttonSubmit button--primary">TEST</div>
<div class="widget-buttonCancel button">TEST</div>
</div>
</body>
</html>
// ----
// Sass (v3.4.0.rc.3)
// Compass (v1.0.0.rc.1)
// ----
.button,
[class*=button--] {
padding: 10px;
display: inline-block;
background-color: #000;
color:#fff;
}
[class*=button--primary] {
border-radius: 10px;
}
.button--primaryAlt {
border-top: 5px solid blue;
}
.widget {
background: #ccc;
padding: 10px;
display: inline-block;
$root: str-slice(#{&}, 2);
@at-root [class*=#{$root}-button] {
background-color: yellow;
color: #000;
}
}
.button,
[class*=button--] {
padding: 10px;
display: inline-block;
background-color: #000;
color: #fff;
}
[class*=button--primary] {
border-radius: 10px;
}
.button--primaryAlt {
border-top: 5px solid blue;
}
.widget {
background: #ccc;
padding: 10px;
display: inline-block;
}
[class*=widget-button] {
background-color: yellow;
color: #000;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<span class="a button a">WHOA</span>
<span class="a button--primary a">WHOA</span>
<span class="a button--primaryAlt a">WHOA</span>
<div class="widget">
<div class="widget-buttonSubmit button--primary">TEST</div>
<div class="widget-buttonCancel button">TEST</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment