Skip to content

Retina Quality CSS

02.17.2011

Setting Up Your Files
Designing for Retina Quality devices such as the iPhone require two sets of images. Let’s take for example this image:

images/myImage.jpg

On a normal device, this would appear at 150×75. But when designing for a device with RQ display, you will need a second image in the same directory, at 300×150.

The Code
Unfortunately, older devices such as the iPhone 3 do not support the same codes that the iPhone 4 and iPad support. This means, we need two separate sets of CSS code. The first set will display the image as it should appear on non-RQ devices.

.myImage {
height: 75px;
width: 150px;
background: url(“images/myImage.jpg”);
}

Now, we have to check to see if the device has an RQ display.

@media screen and (-webkit-device-pixel-ratio: 2) {}

Now simply add your css code inside this check, like so:

@media screen and (-webkit-device-pixel-ratio: 2) {
.myImage {
height: 75px;
width: 150px;
background: url(“images/myImagex2.jpg”);
background-size: 100%;
}
}

Notice the image is myImagex2.jpg. This is your image at double it’s original size, which is resized by the device’s browser to the container’s size, thus doubling the pixels shown.

Advertisement
No comments yet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.