Last active
April 12, 2020 19:41
-
-
Save nikola-wd/9f0902aaf353c0cef6515da746b10a8f to your computer and use it in GitHub Desktop.
[Media Queries Scss Mixin] - SASS Mixin #sass #scss #mixin
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
| // Define the breakpoints | |
| $breakpoint-small: 600px; | |
| $breakpoint-med-small: 960px; | |
| $breakpoint-med: 1175px; | |
| @mixin screen($size, $type: max, $pixels: $breakpoint-small) { | |
| @if $size == 'small' { | |
| @media screen and ($type + -width: $breakpoint-small) { | |
| @content; | |
| } | |
| } | |
| @else if $size == 'med-small' { | |
| @media screen and ($type + -width: $breakpoint-med-small) { | |
| @content; | |
| } | |
| } | |
| @else if $size == 'med' { | |
| @media screen and ($type + -width: $breakpoint-med) { | |
| @content; | |
| } | |
| } | |
| @else if $size == 'large' { | |
| @media screen and ($type + -width: $breakpoint-med) { | |
| @content; | |
| } | |
| } | |
| @else if $size == 'custom' { | |
| @media screen and ($type + -width: $pixels + px) { | |
| @content; | |
| } | |
| } | |
| @else { | |
| @content; | |
| } | |
| } | |
| // TO USE MIXIN, WRITE | |
| .foo { | |
| @include screen(large) { | |
| width: 20%; | |
| } | |
| @include screen(med) { | |
| width: 40%; | |
| } | |
| @include screen(med-small) { | |
| width: 60%; | |
| } | |
| @include screen(small) { | |
| width: 80%; | |
| } | |
| @include screen(custom, max, 400) { | |
| width: 100%; | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment