James Tettelbach-Whitehouse
Responsive web design (RWD) is an approach to web design aimed at crafting sites to provide an optimal viewing and interaction experience across a wide range of devices.
Mobile browsing needs to be great.
Tools of the stone age of mobile web.
Viewport Meta Tag
<meta name="viewport" content="width=device-width, initial-scale=1">
device-width means the width of the page at 100% scale.
Tools of the stone age of mobile web.
Adaptive Design
Coined by Ethan Marcotte in 2010
Allow you to change CSS rules when certain conditions are met.
<link rel='stylesheet' media='screen and (min-width: 768px) and (max-width: 900px)' href='css/medium.css' />
@media screen and (min-width: 768px) and (max-width: 900px) {
width: 100%;
}
or, more commonly:
in HTML <link> tags
directly in the CSS
Media queries deal with more than just browser width!
@media screen and (min-width: 768px) and (max-width: 900px) {
/* Conditional styles for this size */
}
@media print {
/* Conditional styles for printing */
}
@media screen and (min-device-width: 700px) {
/* Conditional styles for DEVICES over 700px */
}
@media all and (orientation: landscape) {
/* Conditional styles for landscape orientation */
}
@media screen and (device-aspect-ratio: 16/9) {
/* Conditional styles for widescreen devices */
}
Images that never clip and are always the right size.
.my-image {
width: 100%;
height: auto;
}
Does that mean an iPhone 3G downloads the same file as the 4k desktop computer?
usually all you need!
363kb in 2010
1125kb in 2015
The <picture> element is easy to read.
<picture>
<source src="small.jpg">
<source src="medium.jpg" media="(min-width: 400px)">
<source src="large.jpg" media="(min-width: 800px)">
</picture>
Better: Stick with <img> and use the 'srcset' attribute.
<img sizes="(max-width: 500px) 100%,
(max-width: 1000px) 50%,
33.333%"
srcset="pic-small.jpg 300w,
pic-medium.jpg 600w,
pic-large.jpg 1000w"
src="small.jpg">
The browser downloads the best image.
Basically, percentage-based layouts.
When you scale down the site, the content and its containers scale down accordingly.
Combine this idea with media queries, and you have fluid grid systems...
We need to talk about fitting into boxes.
By default, CSS is stupid.
* {
box-sizing: border-box;
}
/* extra strength version */
html {
box-sizing: border-box;
}
*, *::before, *::after {
box-sizing: inherit;
}
ENHANCE!
Vector graphics don't rely on pixels, so they scale well.
(Scalable Vector Graphics)
Why?
What?
Mobile First is a strategy for designing websites.
"Build for mobile, then gradually adjust the layout as the screen size increases."
Answer: Mobile First is usually responsive.
Responsive web design (RWD) is an approach to web design aimed at crafting sites to provide an optimal viewing and interaction experience across a wide range of devices.