Skip to content

Instantly share code, notes, and snippets.

@xavierartot
Created August 13, 2015 15:38
Show Gist options
  • Save xavierartot/44c48369852e9161f2d2 to your computer and use it in GitHub Desktop.
Save xavierartot/44c48369852e9161f2d2 to your computer and use it in GitHub Desktop.
Responsive Breakpoints
https://web-design-weekly.com/2013/05/12/handy-sass-mixins/
My most utilised mixin that I don’t think I could live without anymore. Just set your breakpoint at whatever width you desire and go crazy.
@mixin breakpoint($point) {
@if $point == large {
@media (min-width: 64.375em) { @content; }
}
@else if $point == medium {
@media (min-width: 50em) { @content; }
}
@else if $point == small {
@media (min-width: 37.5em) { @content; }
}
}
Usage:
.page-wrap {
width: 75%;
@include breakpoint(large) { width: 60%; }
@include breakpoint(medium) { width: 80%; }
@include breakpoint(small) { width: 95%; }
}
Output:
.page-wrap {
width: 75%;
}
@media (min-width: 64.375em) {
.page-wrap {
width: 60%;
}
}
@media (min-width: 50em) {
.page-wrap {
width: 80%;
}
}
@media (min-width: 37.5em) {
.page-wrap {
width: 95%;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment