Last active
December 25, 2015 12:29
-
-
Save nexxos/6977000 to your computer and use it in GitHub Desktop.
Cheat sheet for responsive web design / media queries.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tips for refining media queries with logic (AND, OR, NOT, ...), see:
http://css-tricks.com/logic-in-media-queries/