Last active
August 29, 2015 14:14
-
-
Save MichaelArestad/dfc648abdfcbbad8aa0b 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.9) | |
// Compass (v1.0.1) | |
// ---- | |
// ========================================================================== | |
// Breakpoint Mixin | |
// ========================================================================== | |
$breakpoints: 320px, 600px, 900px; | |
@mixin breakpoint( $size ){ | |
@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; | |
value: $and-smaller; | |
true: $approved-value; | |
} | |
} | |
@else { | |
@if $size == $and-larger { | |
$approved-value: 2; | |
@media ( min-width: $breakpoint + 1 ) { | |
@content; | |
value: $and-larger; | |
true: $approved-value; | |
} | |
} | |
@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; | |
value: $range; | |
true: $approved-value; | |
} | |
} | |
} | |
} | |
} | |
} | |
@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 ) } ]"; | |
} | |
} | |
body { | |
@include breakpoint( "<320px" ){ | |
// content | |
} | |
@include breakpoint( "<600px" ){ | |
// content | |
} | |
@include breakpoint( "<900px" ){ | |
// content | |
} | |
@include breakpoint( ">320px" ){ | |
// content | |
} | |
@include breakpoint( ">600px" ){ | |
// content | |
} | |
@include breakpoint( ">900px" ){ | |
// content | |
} | |
@include breakpoint( "320px-900px" ){ | |
// content | |
} | |
// @include breakpoint( "320pcsadfx-905px" ){ | |
// uncomment to throw syntax error | |
// } | |
// @include breakpoint( 320px ){ | |
// uncomment to throw string error | |
// } | |
} |
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 (max-width: 320px) { | |
body { | |
value: "<320px"; | |
true: 1; | |
} | |
} | |
@media (max-width: 600px) { | |
body { | |
value: "<600px"; | |
true: 1; | |
} | |
} | |
@media (max-width: 900px) { | |
body { | |
value: "<900px"; | |
true: 1; | |
} | |
} | |
@media (min-width: 321px) { | |
body { | |
value: ">320px"; | |
true: 2; | |
} | |
} | |
@media (min-width: 601px) { | |
body { | |
value: ">600px"; | |
true: 2; | |
} | |
} | |
@media (min-width: 901px) { | |
body { | |
value: ">900px"; | |
true: 2; | |
} | |
} | |
@media (min-width: 321px) and (max-width: 900px) { | |
body { | |
value: "320px-900px"; | |
true: 3; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment