Skip to content

Instantly share code, notes, and snippets.

@anton-chernianu
Last active September 11, 2018 13:06
Show Gist options
  • Save anton-chernianu/c357807939d8acebe69781f60220edd5 to your computer and use it in GitHub Desktop.
Save anton-chernianu/c357807939d8acebe69781f60220edd5 to your computer and use it in GitHub Desktop.
SCSS media mixin
#sidebar {
float: left;
width: 300px;
@include respond-to(tablet-p) { float: none; }
@include respond-to(tablet-l) { float: none; }
@include respond-to(mobile-p) { width: 240px; }
}
@mixin respond-to($media) {
@if $media == tablet-p {
@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) { @content; }
} @else if $media == tablet-l {
@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) { @content; }
} @else if $media == mobile-p {
@media (min-width: 320px) and (max-width: 480px) { @content; }
} @else if $media == mobile-l {
@media (min-width: 481px) and (max-width: 767px) { @content; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment