Skip to content

Instantly share code, notes, and snippets.

@jdsteinbach
Created May 13, 2014 13:30
Show Gist options
  • Save jdsteinbach/3e6b586921f9556856fd to your computer and use it in GitHub Desktop.
Save jdsteinbach/3e6b586921f9556856fd to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// 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/
*/
.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