-
-
Save babsgosgens/01934a7d1644e5bb8329 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---- | |
// Sass (v3.3.8) | |
// Compass (v1.0.0.alpha.19) | |
// ---- | |
$red: #ff4242; | |
// Declare this variable early | |
$parent-classes: (); | |
// This mixin holds the style code you want to repeat | |
@mixin grid() { | |
width: 100%; | |
&-item { | |
width: 33%; | |
padding: 1em; | |
&-title { | |
color: $red; | |
text-transform: uppercase; | |
} | |
} | |
} | |
// In _products.scss: | |
$parent-classes: append($parent-classes, #{'.products-grid'}, comma); | |
// In _services.scss: | |
$parent-classes: append($parent-classes, #{'.services-grid'}, comma); | |
// In _industries.scss: | |
$parent-classes: append($parent-classes, #{'.industries-grid'}, comma); | |
// Do this near the end: | |
#{$parent-classes} { | |
@include grid(); | |
} | |
/* Read the detailed explanation behind this gist here: | |
http://jamessteinbach.com/css/sass/creating-repeatable-style-pattern-sass-placeholders-vs-mixins/ | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.products-grid, .services-grid, .industries-grid { | |
width: 100%; | |
} | |
.products-grid-item, .services-grid-item, .industries-grid-item { | |
width: 33%; | |
padding: 1em; | |
} | |
.products-grid-item-title, .services-grid-item-title, .industries-grid-item-title { | |
color: #ff4242; | |
text-transform: uppercase; | |
} | |
/* Read the detailed explanation behind this gist here: | |
http://jamessteinbach.com/css/sass/creating-repeatable-style-pattern-sass-placeholders-vs-mixins/ | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment