Skip to content

Instantly share code, notes, and snippets.

@bpainter
Created April 16, 2013 12:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bpainter/5395420 to your computer and use it in GitHub Desktop.
Save bpainter/5395420 to your computer and use it in GitHub Desktop.
A CodePen by Bermon Painter. @content directive
<h1>@content directive</h1>
<p>We can take our media queries a step farther and create a mixin out of them. The @content directive in Sass allows you to pass entire sections of CSS rules back through a mixin.</p>
<article role="main">
Main content
</article>
<aside role="complementary">
Secondary content
</aside>
@import "compass";
h1 {
font-size: 20px;
}
article, aside {
background-color: #ccc;
margin-bottom: 20px;
min-height: 80px;
}
$small-breakpoint: 480px;
$medium-breakpoint: 768px;
$large-breakpoint: 960px;
@mixin respond-to($name){
@if $name == small-screen {
@media only screen and (min-width: $small-breakpoint) {
@content
}
}
@if $name == medium-screen {
@media only screen and (min-width: $medium-breakpoint) {
@content

}
}
@if $name == large-screen {
@media only screen and (min-width: $large-breakpoint) {
@content

}
}
}
article {
width: 100%;
@include respond-to(small-screen) {
background-color: #999;
float: left;
width: 70%;
}
@include respond-to(medium-screen) {
background-color: #666;
width: 60%;
}
@include respond-to(large-screen) {
background-color: #333;
width: 48%;
}
}
aside {
width: 100%;
@include respond-to(small-screen) {
background-color: #999;
float: right;
width: 25%;
}
@include respond-to(medium-screen) {
background-color: #666;
width: 35%;
}
@include respond-to(large-screen) {
background-color: #333;
width: 48%;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment