Data Source
Layout is a part of presentation,
it defines positioning, flow.
Design needs to be fluid,
flexible, define with percent.
Content needs to be adaptive,
/* Large desktop */
@media (min-width: 1200px) { ... }
/* Portrait tablet to landscape and desktop */
@media (min-width: 768px) and (max-width: 979px) { ... }
/* Landscape phone to portrait tablet */
@media (max-width: 767px) { ... }
/* Landscape phones and down */
@media (max-width: 480px) { ... }
@media
(-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {
/* Retina-specific stuff here */
}
.ico{ background-image: url('img-1.png');/*size 256px 256px*/ background-size: 16em 16em; }
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) { .ico{ background-image: url('img-2.png');/*size 512px 512px density 2*/ } }
<img alt="A rad wolf" srcset="pic1x.jpg 1x, pic2x.jpg 2x, pic4x.jpg 4x"
src="pix1x.jpg" width="500" height="500">
<picture> <source media="(min-width: 45em)" srcset="large.jpg"> <source media="(min-width: 18em)" srcset="med.jpg"> <img src="small.jpg" alt="The president giving an award."> </picture>
Can we use it now ?
Polyfill ?
Browser are not ready
<noscript data-src-small="img-small.jpg"
data-src-medium="img-medium.jpg"
data-src-high="img-high"
data-src-x-high="img-x-high.jpg">
<img src="img-small.jpg">
</noscript>
var screenPixelRatio = function () {
var retVal = 1;
if (win.devicePixelRatio) {
retVal = win.devicePixelRatio;
} else if ("matchMedia" in win && win.matchMedia) {
if (win.matchMedia("(min-resolution: 2dppx)").matches {
retVal = 2;
}
}
return retVal;
}