Skip to content

Instantly share code, notes, and snippets.

@ArturT
Last active April 17, 2019 10:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ArturT/2eaef5769923ac85ab2f23349ea6d552 to your computer and use it in GitHub Desktop.
Save ArturT/2eaef5769923ac85ab2f23349ea6d552 to your computer and use it in GitHub Desktop.
BEM mix example
<!DOCTYPE html>
<html>
<head>
<style>
/*
* This won't work (Sass syntax - compile first)
*/
.nav {
&__logo {
// change behavior of logo only in context of nav
// e.g. set position of logo in footer
}
}
.footer {
&__logo {
// change behavior of logo only in context of footer
// e.g. set position of logo in footer
}
}
.menu {
color: blue; // blue links off season
&_christmas &__link {
color: red; // red links during christmas
}
}
</style>
</head>
<body>
<nav class="nav">
<img src="logo.png" class="logo nav__logo">
<h1>My webpage</h1>
<ul class="menu menu_christmas">
<li class="menu__link">Link 1</li>
<li class="menu__link">Link 2</li>
<li class="menu__link">Link 3</li>
</ul>
</nav>
<main>
<!-- page content -->
</main>
<footer class="footer">
<img src="logo.png" class="logo footer__logo">
<p>Copyright &copy; My webpage</p>
</footer>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment