Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Two images can have the same resolution but different dpi. This is the important part in retina displays, therefore, you need two versions (if you want to save some bandwith for those that doesn't have retina) of you image with different dpi's.</p> <p>For further information on how to add a rule in css, and some dpi values take a look at: <a href="http://css-tricks.com/snippets/css/retina-display-media-query/" rel="nofollow">Retina Display Media Query</a>.</p> <p><strong>EDIT</strong> As pointed out by a comment from @carlos-r-balebona, bandwith will not be saved if embed the image into the CSS, as both versions will always be sent. It will only be saved if you use image URLs as only the proper one will be downloaded.</p> <p><strong>EDIT WITH EXAMPLE</strong></p> <p>OK, here's an example:</p> <p>Suppose you have 2 images (data:image/png;base64,{192_dpi_encoded_image}) and (data:image/png;base64,{96_dpi_encoded_image}).</p> <p>Now suppose you have a div you want to set the background image to:</p> <pre><code>&lt;div id="a" style="width: 100px; height:100px;"&gt; &lt;/div&gt; </code></pre> <p>And in your css:</p> <pre><code>@media only screen { #a { background:url(data:image/png;base64,{96_dpi_encoded_image}); } } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and ( min-device-pixel-ratio: 2), only screen and ( min-resolution: 192dpi), only screen and ( min-resolution: 2dppx){ #a { background:url(data:image/png;base64,{192_dpi_encoded_image}); } } </code></pre> <p>The last @media with conditions will override the background image set before only if there's a retina screen present, thus, setting the large dpi image when needed.</p> <p>Hope this helps.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload