Skip to content

Instantly share code, notes, and snippets.

@witmin
Last active May 8, 2021 16:21
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save witmin/5cdb7a2e3cac9b39f3d6 to your computer and use it in GitHub Desktop.
Save witmin/5cdb7a2e3cac9b39f3d6 to your computer and use it in GitHub Desktop.
Simple media queries mixins for phone and tablet. Including variables of the basic mobile size, portrait and landscape orientation in sass. Can be quick applied in a mini site.
//Simple media queries mixins for phone and tablet. Including variables of the basic mobile size, portrait and landscape orientation in sass. Can be quick applied in a mini site.
// Author: Millie Lin
// website: www.millielin.com
// ***** Breakpoints for Responsive Screen
// width scale for phone
$phone-min-width: 320px !default;
$phone-max-width: 504px !default;
// height scale for phone
$phone-min-height: 346px !default;
$phone-max-height: 695px !default;
// width scale for tablet
$tablet-min-width: 480px !default;
$tablet-max-width: 1024px !default;
// height scale for tablet
$tablet-min-height: 800px !default;
$tablet-max-height: 1440px !default;
// Desktop Scale
$desktop-min-height: 768px !default;
$desktop-max-height: 1280px !default;
// Mixins
// For portrait phone and landscape phone
@mixin phone(){
@media screen and (min-width: $phone-min-width) and (max-height: $phone-max-height){
@content;
}
}
// For portrait phone
@mixin portrait-phone() {
@media screen and (min-width: $phone-min-width) and (max-width: $phone-max-width) and (orientation: portrait) {
@content;
}
}
// For landscape phone
@mixin landscape-phone(){
@media screen and (min-height: $phone-min-height) and (max-height: $phone-max-height) and (orientation: landscape){
@content;
}
}
// For portrait tablet and landscape tablet
@mixin tablet(){
@media screen and (min-width: $tablet-min-width) and (max-height: $tablet-max-height){
@content;
}
}
// For portrait tablet
@mixin portrait-tablet() {
@media screen and (min-width: $tablet-min-width) and (max-width: $tablet-max-width) and (orientation: portrait) {
@content;
}
}
// For landscape tablet
@mixin landscape-tablet(){
@media screen and (min-height: $tablet-min-height) and (max-height: $tablet-max-height) and (orientation: landscape){
@content;
}
}
// For desktop
@mixin desktop(){
@media screen and (min-height: $desktop-min-height) and (max-height: $desktop-max-height){
@content;
}
}
@witmin
Copy link
Author

witmin commented Apr 28, 2016

Added the media query for desktop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment