Skip to content

Instantly share code, notes, and snippets.

@levinelson
Last active January 4, 2016 03:38
Show Gist options
  • Save levinelson/8562695 to your computer and use it in GitHub Desktop.
Save levinelson/8562695 to your computer and use it in GitHub Desktop.
// Creates breakpoints every 100px up to 1900
// Usage: respond(2) makes a media query with min-width 200
// respond(16, ie) makes a media querey for 1600 on up AND IE8
@mixin respond($size, $ie:false) {
$i: 1;
@while $i < 19 {
@if $size == $i {
@media only screen and (min-width: #{$i*100}px) {
@content;
}
}
$i: $i + 1;
}
// If IE argument is passed in, apply the styles to pages with class .ie8
@if $ie == ie {
html.ie8 & {
@content;
}
}
// Apply ALL styles right away to old pages with .desktop-only class
.desktop-only & {
@content;
}
}
// Example
.your-element {
// Default mobile-first styles here
@include respond(3) {
// Styles for screens from 300px on up
}
@include respond(6, ie) {
// Styles for screens from 600px on up AND IE8
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment