The control which designers know in the print medium... is simply a function of the limitation of the printed page.
We should embrace the fact that the web doesn't have the same constraints, and design for this flexibility.
~ John Allsopp, A Dao of Web Design
First, there was the desktop
Then there was mobile
But is that enough anymore?
Tablets are somewhere in the middle
Mobile devices are used in many ways
It's time for a paradigm shift
The ingredients:
Ethan Marcotte in Responsive Web Design (2010)
Proportional design
But what about those pretty Photoshop designs?
Works for widths, heights, fonts, margins, etc.
|
|
|
|
|
|
Flexible grid still has limits
Flexible grid can...
Enter the media query
@media screen and (max-width: 479px){
.ex {
// ...
}
}
Many detectable features available
@media (max-width: 479px){ } @media (min-width: 480px){ }
@media (max-height: 479px){ } @media (min-height: 480px){ }
@media (max-device-width: 479px){ } @media (min-device-width: 480px){ }
@media (max-device-height: 479px){ } @media (min-device-height: 480px){ }
@media (orientation: portrait){ } @media (orientation: landscape){ }
@media (min-aspect-ratio: 16/9){ } @media (max-aspect-ratio: 16/9){ }
@media (min-deviceaspect-ratio: 3/2){ } @media (device-aspect-ratio: 16/9){ }
@media (min-color: 8){ } @media (max-color: 32){ }
@media (min-color-index: 256){ } @media (max-color-index: 65536){ }
@media (min-resolution: 300dpi){ } @media (max-resolution:299dpi){ }
@media (min-resolution: 300dpi){ } @media (max-resolution:299dpi){ }
Chain multiple together with and
keyword
@media (min-width: 480px) and (max-width:799px) { }
|
|
|
|
Images have a fixed size
...so what happens when we go fluid?
But that's not how Opera's site looks!
What did they do?
img {
max-width: 100%;
}
Richard Rutter in Images in liquid columns (2003)
Yep, that's it!
What about other media?
img, embed, object, video {
max-width: 100%;
}
Scaling looks bad in IE
#my-image{
background: none;
filter: progid:DXImageTransform.Micrisoft.AlphaImageLoader(
src="/img/example.png", sizingMethod="scale");
}
But we're still wasting bytes...
<img src="/img/small.jpg" alt="My Image" class="small">
<img src="/img/medium.jpg" alt="My Image" class="medium">
<img src="/img/large.jpg" alt="My Image" class="large">
@media screen and (min-width: 600px) {
.small, .medium { display: none; }
}
@media screen and (min-width: 440px) {
.small, .large { display: none; }
}
@media screen and (max-width: 439px) {
.medium, .large { display: none; }
}
<figure class="responsive" title="My Image"
data-media440="/img/medium.png" data-media600="/img/large.png"
data-media="/img/small.png">
<noscript>
<img src="/img/large.png" alt="My Image">
</noscript>
</figure>
<picture alt="My Image">
<source src="/img/small.png">
<source src="/img/medium.png" media="(min-width:440px)">
<source src="/img/large.png" media="(min-width:600px)">
<noscript>
<img src="/img/large.png" alt="My Image">
</noscript>
</picture>
MWF can do compression from a server farm
<img src="assets/min/img.php?img=http%3A%2F%2Fdomain%2Fimg%2Fexample.png">
Adaptive Images uses .htaccess to compress transparently
Numerous other libraries out there as well
Not technically part of responsive design
but an effective strategy for building responsive sites
min-width
, not max-width
Progressive enhancement, not graceful degradation
These techniques are supported by modern browsers, but...
Responsive design is a viable choice today
... if not almost the obvious choice
And it is the future of MWF