Skip to content

Instantly share code, notes, and snippets.

@ticking-clock
Last active March 1, 2017 15:54
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ticking-clock/6355082 to your computer and use it in GitHub Desktop.
Save ticking-clock/6355082 to your computer and use it in GitHub Desktop.
Common media queries with LESS
@media only screen and (max-width: 767px) {
}
@media only screen and (min-width: 768px) {
}
@media only screen and (min-width: 992px) {
}
@media only screen and (min-width: 1200px) {
}
@media only screen and (min-width: 768px) and (max-width: 991px) {
}
@media only screen and (min-width: 992px) and (max-width: 1199px) {
}
// Common media queries breakpoints (incl Bootstrap)
// -------------------------------------------------
// Extra small screen / phone
@screen-xs-min: 480px;
// Small screen / tablet
@screen-sm-min: 768px;
// Medium screen / desktop
@screen-md-min: 992px;
// Large screen / wide desktop
@screen-lg-min: 1200px;
// So media queries don't overlap when required, provide a maximum
@screen-xs-max: (@screen-sm-min - 1);
@screen-sm-max: (@screen-md-min - 1);
@screen-md-max: (@screen-lg-min - 1);
// Common pre-built queries
@phone: ~"only screen and (max-width: @{screen-xs-max})";
@tablet: ~"only screen and (min-width: @{screen-sm-min})";
@medium: ~"only screen and (min-width: @{screen-md-min})";
@large: ~"only screen and (min-width: @{screen-lg-min})";
// For specifying only a particular range of screen sizes
@tablet-only: ~"only screen and (min-width: @{screen-sm-min}) and (max-width: @{screen-sm-max})";
@medium-only: ~"only screen and (min-width: @{screen-md-min}) and (max-width: @{screen-md-max})";
@media @phone {}
@media @tablet {}
@media @medium {}
@media @large {}
@media @tablet-only {}
@media @medium-only {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment