August 2015
Intermediate to advanced
312 pages
7h 3m
English
Thanks to media queries, we have the ability to load in different background images, not just at different viewport sizes but also different viewport resolutions.
For example, here is the official way of specifying a background image for a 'normal' and a high DPI screen. You can find this in example_06-07:
.bg {
background-image: url('bg.jpg');
}
@media (min-resolution: 1.5dppx) {
.bg {
background-image: url('bg@1_5x.jpg');
}
}The media query is written exactly as it is with width, height, or any of the other capability tests. In this example, we are defining the minimum resolution that bg@1_5x.jpg should use as 1.5dppx (device pixels per CSS pixel). We could also use dpi (dots per inch) or dpcm (dots per centimeter ...
Read now
Unlock full access