Breakpoints by Name - mobile first and custom - SASS

/* USAGE: // Declare the $breakpoints variable $breakpoints: ( 'tiny': ( max-width: 767px ), 'small': ( min-width: 768px ), 'medium': ( min-width: 992px ), 'large': ( min-width: 1200px ), 'custom': ( min-height: 40em ) ); .sample { color: #000; @include breakpoint(medium) { color: blue; } } */ @mixin breakpoint($name) { @if map-has-key($breakpoints, $name) { @media #{inspect(map-get($breakpoints, $name))} { @content; } } @else { @warn "Couldn't find a breakpoint named `#{$name}`."; } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.