Full Responsive
Sven Wolfermann
@maddesigns
Sven Wolfermann
@maddesigns
2010 “We need a mobile site!”
2012 “Let's make it responsive!”
2014 “Holy crap!”
My Slides: http://maddesigns.de/responsive-workflow/
*, *:before, *:after { box-sizing: border-box; }
understand the viewport
<meta name="viewport" content="width=device-width,initial-scale=1.0">
Simple Grids: 50%, 33%, 25%, …
many Gridsystems…
http://codepen.io/maddesigns/full/EBlHd/
http://codepen.io/maddesigns/full/yJdiL/
.grid {
max-width: 1280px;
display: flex;
flex-wrap: wrap;
}
.card {
flex: 1 0 250px;
}
Blog-Post (german)
@media (min-width: 40em) {
ul {
columns: 2;
}
}
@media (min-width: 60em) {
ul {
columns: 3;
}
}
@media (min-width: 80em) {
ul {
columns: 4;
}
}
p {
columns: 3 20em;
}
It’s easy to make a bunch of boxes responsive
Teaser
img {
min-width: 50%; /* value to use above 400px */
width: calc((400px - 100%) * 400); /* 400px "breakpoint" */
max-width: 100%; /* value to use below 400px */
}
http://codepen.io/maddesigns/pen/LeqEu
Fallback: http://codepen.io/maddesigns/pen/sAjgo
http://codepen.io/maddesigns/pen/pHqnt
Blog-Post (german)
For third party widgets, sometimes you just have to to do…
table[width=“575px”] {
width: 100%;
}
1vw = 1% of viewport width 1vh = 1% of viewport height 1vmin = 1vw or 1vh, whichever is smaller 1vmax = 1vw or 1vh, whichever is larger
Usage:
h1 { font-size: 5.9vw; } h2 { font-size: 3.0vh; } p { font-size: 2vmin; }
h1 {
font-size: calc(4vw + 4vh + 2vmin);
}
<article>
<p>…</p>
<div class="full-width">
<img src="image.jpg">
</div>
<p>…</p>
</article>
CSS
article {
max-width: 80em;
margin: 0 auto;
}
.full-width {
margin: 0 calc(-50vw + 50%);
}
A compressed copy of the Doom (1993) installer was 2.34 Mb
<picture> & srcset + sizes
<img
srcset=" large.jpg 1200w,
medium.jpg 600w,
small.jpg 360w"
sizes=" (min-width: 50em) 33vw,
(min-width: 28em) 50vw,
100vw"
src="small.jpg"
alt="alttext"
/>
picture/srcset has native support in all major browser
use respimage or picturefill for cross browser-support
Picture:
<picture>
<source srcset="http://unsplash.it/640/360" media="(min-width: 640px)" alt="image only for screens up to 640px">
<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" alt="">
</picture>
http://codepen.io/maddesigns/pen/zGdbBY
srcset:
<img srcset="http://unsplash.it/640/360 640w"
src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"
sizes="(min-width: 640px) 100vw, 0" alt="">
Sven Wolfermann | @maddesigns | maddesigns.de