Created
June 10, 2015 18:51
-
-
Save MichaelArestad/c00db22ed4882680fc91 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
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.4.14) | |
// Compass (v1.0.3) | |
// ---- | |
$media-queries: true; | |
$breakpoints: 480px, 660px, 960px; // Think very carefully before adding a new breakpoint | |
@mixin breakpoint( $size ){ | |
@if ( $media-queries == true ) { | |
@if type-of($size) == string { | |
$approved-value: 0; | |
@each $breakpoint in $breakpoints { | |
$and-larger: ">" + $breakpoint; | |
$and-smaller: "<" + $breakpoint; | |
@if $size == $and-smaller { | |
$approved-value: 1; | |
@media ( max-width: $breakpoint ) { | |
@content; | |
} | |
} | |
@else { | |
@if $size == $and-larger { | |
$approved-value: 2; | |
@media ( min-width: $breakpoint + 1 ) { | |
@content; | |
} | |
} | |
@else { | |
@each $breakpoint-end in $breakpoints { | |
$range: $breakpoint + "-" + $breakpoint-end; | |
@if $size == $range { | |
$approved-value: 3; | |
@media ( min-width: $breakpoint + 1 ) and ( max-width: $breakpoint-end ) { | |
@content; | |
} | |
} | |
} | |
} | |
} | |
} | |
@if $approved-value == 0 { | |
$sizes: ""; | |
@each $breakpoint in $breakpoints { | |
$sizes: $sizes + " " + $breakpoint; | |
} | |
@error "ERROR in breakpoint( #{ $size } ): You can only use these sizes [ #{$sizes} ] using the following syntax [ <#{ nth( $breakpoints, 1 ) } >#{ nth( $breakpoints, 1 ) } #{ nth( $breakpoints, 1 ) }-#{ nth( $breakpoints, 2 ) } ]"; | |
} | |
} | |
@else { | |
$sizes: ""; | |
@each $breakpoint in $breakpoints { | |
$sizes: $sizes + " " + $breakpoint; | |
} | |
@error "ERROR in breakpoint( #{ $size } ): Please wrap the breakpoint $size in parenthesis. You can use these sizes[ #{$sizes} ] using the following syntax [ <#{ nth( $breakpoints, 1 ) } >#{ nth( $breakpoints, 1 ) } #{ nth( $breakpoints, 1 ) }-#{ nth( $breakpoints, 2 ) } ]"; | |
} | |
} | |
} | |
.test { | |
@include breakpoint( '>480px' ) { | |
color: red; | |
} | |
} |
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
@media (min-width: 481px) { | |
.test { | |
color: red; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment