Skip to content

Instantly share code, notes, and snippets.

@mavieth
Last active April 18, 2024 21:53
Show Gist options
  • Star 56 You must be signed in to star a gist
  • Fork 20 You must be signed in to fork a gist
  • Save mavieth/e0c8fdcb72a30d85f57a to your computer and use it in GitHub Desktop.
Save mavieth/e0c8fdcb72a30d85f57a to your computer and use it in GitHub Desktop.
Media Query Template for Basic CSS
/**
* Basic CSS Media Query Template
* TODO: I should probably use Sass...
* Author: Michael Vieth
* ------------------------------------------
* Responsive Grid Media Queries - 1280, 1024, 768, 480
* 1280-1024 - desktop (default grid)
* 1024-768 - tablet landscape
* 768-480 - tablet
* 480-less - phone landscape & smaller
* --------------------------------------------
*/
@media all and (min-width: 1024px) and (max-width: 1280px) { }
@media all and (min-width: 768px) and (max-width: 1024px) { }
@media all and (min-width: 480px) and (max-width: 768px) { }
@media all and (max-width: 480px) { }
/* Portrait */
@media screen and (orientation:portrait) { /* Portrait styles here */ }
/* Landscape */
@media screen and (orientation:landscape) { /* Landscape styles here */ }
/* CSS for iPhone, iPad, and Retina Displays */
/* Non-Retina */
@media screen and (-webkit-max-device-pixel-ratio: 1) {
}
/* Retina */
@media only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (-o-min-device-pixel-ratio: 3/2),
only screen and (min--moz-device-pixel-ratio: 1.5),
only screen and (min-device-pixel-ratio: 1.5) {
}
/* iPhone Portrait */
@media screen and (max-device-width: 480px) and (orientation:portrait) {
}
/* iPhone Landscape */
@media screen and (max-device-width: 480px) and (orientation:landscape) {
}
/* iPad Portrait */
@media screen and (min-device-width: 481px) and (orientation:portrait) {
}
/* iPad Landscape */
@media screen and (min-device-width: 481px) and (orientation:landscape) {
}
@NeeONCorp
Copy link

Good job! Thanks

@Nevah5
Copy link

Nevah5 commented Apr 7, 2021

Thank you! Is perfect for my school project ;)

@abinashmohanty
Copy link

This is superb. Thanks for saving 24 hours of hard work 😂

@arafatx
Copy link

arafatx commented Dec 1, 2021

Do not use this in 2021, for example -webkit-device-pixel-ratio is not standard and should not be used because it doesn't work for all users. Read here: https://developer.mozilla.org/en-US/docs/Web/CSS/@media/-webkit-device-pixel-ratio

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