Skip to content

Instantly share code, notes, and snippets.

@keithchu
Created September 26, 2015 03:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save keithchu/ebb0261c3ee00e387f93 to your computer and use it in GitHub Desktop.
Save keithchu/ebb0261c3ee00e387f93 to your computer and use it in GitHub Desktop.
Responsive mixin for easy media queries
// define breakpoints
$small: #{"screen and (max-width: 479px)"}
$medium: #{"screen and (min-width: 480px) and (max-width: 767px)"}
$large: #{"screen and (min-width: 768px)"}
// define mixin
=respond-to($media...)
$media-list: null
@each $query in $media
$media-list: append($media-list, unquote("#{$query}"), comma)
@media #{$media-list}
@content
// profit!
.selector
+respond-to($small)
color: rebeccapurple
+respond-to($medium, $large)
color: blanchedalmond
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment