Skip to content

Instantly share code, notes, and snippets.

@etoxin
Created June 9, 2016 02:23
Show Gist options
  • Save etoxin/2a31822b1ddb3da84b431837d18370be to your computer and use it in GitHub Desktop.
Save etoxin/2a31822b1ddb3da84b431837d18370be to your computer and use it in GitHub Desktop.
<h1 class="test">Responsive: </h1>
// Example use:
// @include respond(desktop) {
// .example {
// color: red;
// }
// }
@mixin respond($breakpoint) {
@if $breakpoint == mobile-only {
@media screen and (max-width: 768px) and (orientation: portrait) {
@content;
}
}
@if $breakpoint == tablet-portrait {
@media screen and (min-width: 768px) and (orientation: portrait) {
@content;
}
}
@if $breakpoint == tablet-landscape {
@media screen and (min-width: 1024px) and (orientation: landscape) {
@content;
}
}
@if $breakpoint == desktop {
@media screen and (min-width: 1260px) {
@content;
}
}
@if $breakpoint == desktop-hd {
@media screen and (min-width: 1920px) {
@content;
}
}
}
// Example Usage
.test {
&::after {
content: 'Mobile'
}
@include respond('tablet-portrait') {
&::after {
content: 'tablet-portrait'
}
}
@include respond('tablet-landscape') {
&::after {
content: 'tablet-landscape'
}
}
@include respond('desktop') {
&::after {
content: 'desktop'
}
}
@include respond('desktop-hd') {
&::after {
content: 'desktop-hd'
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment