Skip to content

Instantly share code, notes, and snippets.

@pfulton
Created September 12, 2012 15:55
Show Gist options
  • Save pfulton/3707635 to your computer and use it in GitHub Desktop.
Save pfulton/3707635 to your computer and use it in GitHub Desktop.
Placeholder Selectors, Mixins and Media Queries: oh my!
/* THE BASE FILE WHERE YOU IMPORT ALL YOUR STUFF & MAYBE DO YOUR MEDIA QUERIES */
@import "mixins";
@media only screen and (min-width: 40.625em) {
@import "lib/placeholders";
@import "layout/medium";
}
/* THE STYLES FOR "MEDIUM" SIZED SCREENS (AS DEFINED IN BASE.SCSS) */
.this-thing {
@extend %thingie;
}
.this-other-thing {
@extend %alternate-thingie;
}
/* A PLACE TO DEFINE YOUR "BASE/ORIGINAL" MIXINS */
@mixin divider-bottom {
padding-bottom: 1em;
border-bottom: 1px solid $border-color;
margin-bottom: 1em;
}
/* PLACEHOLDER SELECTORS. */
%thingie {
background: red;
font-size: 1.25em;
width: 10%;
display: block;
}
%alternate-thingie {
@include divider-bottom;
}
/* THE FINAL, COMPILED CSS */
@media only screen and (min-width: 40.625em) {
.this-thing {
background: red;
font-size: 1.25em;
width: 10%;
display: block;
}
.this-other-thing {
padding-bottom: 1em;
border-bottom: 1px solid #dededb;
margin-bottom: 1em;
}
}
@pfulton
Copy link
Author

pfulton commented Sep 13, 2012

This works, but is not ideal. Things get very inefficiently grouped inside of the media query files, which leads to code bloat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment