Web Design Auckland

Web Design Auckland

Web Design Auckland Overall rating: ☆☆☆☆☆ 0 based on 0 reviews
5 1
Rating

Step Three:

Next, let’s add some CSS code for the Retina image. We’re likely to switch the normal image to some Retina image when the user is on the Retina display.

@media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-device-pixel-ratio: 2) digital)no-repeat width: 778px height: 519px margin: auto

Our media query begins with < @media query statement followed by only, which means only the screen device must execute the code. Then we added min-device-pixel-ratio, which means the screen must be equal or greater that two.

We also added -webkit browser prefix to make sure that our code will work on older Safari browsers. Congratulations!

You just used Media Queries replacement technique. Each time a user will view your web page on their Retina display device, the non-Retina image will be replaced by the Retina image.

Web Design Auckland
Web Design Auckland

jQuery Retina Display Optimization
retinajs

We can also use jQuery to replace images if the user is using a high density device. For this tutorial, we’re going to take advantage of the functionality of retina.js. Retina.js is an open source script that makes it easy to serve high-resolution images to devices with retina displays. Let’s try this out.

Step 1:
Create a new HTML file and name it jqueryRetina.html. On the head section, place the jQuery library source link from Google.

&ltscript type=”text/javascript” src=”//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js”&gt&lt/script&gt
Step 2:
Next, create a new folder for our Retina folder and name it js. Now let’s download retina.js and then place the link code below before your closing tag.

&ltscript type=”text/javascript” src=”js/retina.js.js”&gt&lt/script&gt
Step 3:
Place the following code on our body section. This will include our basic retina image markup with a class of imgRetina.

&lt/pre&gt
&ltdiv class=”imgRetina”&gt&lt/div&gt
&ltpre&gt
Step 4:
Afterwards, inside our internal/external CSS, place this code for our non-Retina image. This contains the source of the image together with its width and the height. Then, in the end, we just center the image using margin: 0 auto.

http://webdesignaucklandnz.win/

https://plus.google.com/+WebdesignaucklandnzWin

https://www.facebook.com/Web-Design-Auckland-367907043553784