Skip to content

Instantly share code, notes, and snippets.

@nexxos
Last active December 25, 2015 12:29
Show Gist options
  • Save nexxos/6977000 to your computer and use it in GitHub Desktop.
Save nexxos/6977000 to your computer and use it in GitHub Desktop.
Cheat sheet for responsive web design / media queries.
<!DOCTYPE HTML>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0" />
<title>test</title>
<style type="text/css">
h1 {
text-align:center;
}
/* Default/small phone Version */
h1:after {
content: ' - small phone';
display: block;
background-color: pink;
}
/* Print Version */
@media print {
h1:after {
content: ' - PRINT';
}
}
/* Phone Version */
@media only screen and (min-width: 320px) {
h1:after {
content: ' - PHONE';
display: block;
background-color: red;
}
}
/* Tablet Version */
@media only screen and (min-width: 768px) {
h1:after {
content: ' - TABLET';
display: inline-block;
background-color: yellow;
}
}
/* Desktop Version */
@media only screen and (min-width: 980px) {
h1:after {
content: ' - DESKTOP';
display: inline;
background-color: green;
}
}
/* HD Desktop Version */
@media only screen and (min-width: 1200px) {
h1:after {
content: ' - DESKTOP HD';
display: inline;
background-color: turquoise;
}
}
</style>
</head>
<body>
<h1>Big Fat Very Long Headline</h1>
</body>
</html>
@nexxos
Copy link
Author

nexxos commented Oct 14, 2013

Tips for refining media queries with logic (AND, OR, NOT, ...), see:
http://css-tricks.com/logic-in-media-queries/

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