Skip to content

Instantly share code, notes, and snippets.

@carlsverre
Created January 13, 2015 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlsverre/36e5d413f738de7bacfd to your computer and use it in GitHub Desktop.
Save carlsverre/36e5d413f738de7bacfd to your computer and use it in GitHub Desktop.
Simple SCSS breakpoint implementation
$breakpoints: (
zero: 0px,
small: 900px,
medium: 1200px,
medium-large: 1400px,
large: 1600px,
xlarge: 2000px
);
@mixin breakpoint($left, $right: null) {
@if $right != null {
@media screen and (min-width: map-get($breakpoints, $left)) and (max-width: map-get($breakpoints, $right) - 1) {
@content;
}
} @else {
@media screen and (min-width: map-get($breakpoints, $left)) {
@content;
}
}
}
.foo {
@include breakpoint(zero, small) {
width: 100px;
}
@include breakpoint(small, medium) {
width: 200px;
}
@include breakpoint(medium) {
width: 300px;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment