CSS Media Queries and their place in Responsive Web Design - http://bit.ly/dwdm_rwd
John Weis
@weisjohn
Senior Web Developer
Resource Interactive
resource.com
It is not the strongest of the species that survives, nor the most intelligent, but the one most responsive to change.
Flexible Grids
Flexible Assets
Media Queries
| target | the element to be sized |
| context | the parent element of target |
| result | relative unit in % or em |
.container { width: 900px; }
.cell { width: 90px; }
.container { width: 90%; /* ~1000px */ }
.cell { width: 10%; /* 90px / 900px */ }
img, object, video { max-width: 100% }
<link rel="stylesheet" type="text/css"
media="screen" href="base.css">
<link rel="stylesheet" type="text/css"
media="print" href="printers.css">
<link rel="stylesheet" type="text/css"
media="all" href="old_site.css">
<link rel="stylesheet" type="text/css"
media="only screen and (min-width:768px)"
href="tablets.css">
<style>
@media only screen and (max-width: 768px) {
/* if a window is > 768px, these rules don't apply */
}
@media only screen and (-webkit-min-device-pixel-ratio:2) {
/* vendor specifics already? */
}
</style>
of just how bad a site can look
even if it's not that complicated
(excuse the fact that it's my site)
Flexible Grids
Flexible Assets
Media Queries
| target | the element to be sized |
| context | the parent element of target |
| result | relative unit usually in % or em |
.container_16 {
width: 66.6667%; /* 960px / 1440px */
padding: 3.1250%; /* 30px / 960px */
}
.grid_16 {
width: 97.91667%; /* 940px / 960px */
margin: 1.04167%; /* 10px / 960px */
}
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
@media only screen and (max-width: 640px) {
.container_16 {
width: 93.7500%; /* 600px / 640px */
padding: 3.1250%; /* 20px / 640px */
margin-top: 0px;
box-shadow: none;
}
.home section p {
font-size: 22px; /* could be relative */
}
header nav {
margin-top: 44px; /* not relative */
}
}