Responsive design: Understanding device pixels, css pixels, and screen resolution

Source: Internet
Author: User

Overview

Screen resolution, device pixels, and CSS pixels these terms, which are interchangeable in very many contexts, are therefore easy to confuse where there are differences, in fact they are different concepts.

Screen resolution and device pixels are physical concepts, while CSS pixels are the concept of Web programming, and the difference between screen resolution and device pixels is the device pixel display density.

When the device screen zoom=100%, the browser CSS pixel size and device pixels are equal, and when the pixel density (pixel density) is 1, the screen resolution and device pixels are equal.

Responsive design

In a responsive design, the Viewport,device-width,media query,width concepts are used, and the Web-application ape needs to understand the nuances accurately.

Media query detects the screen size, device-width the screen width in device pixels, and Width calculates the total page width in css pixels (minimum 980px in the iphone).

Viewport refers to a region in which a browser calculates an element's size by its width ratio, which is usually larger than the screen.

The following meta tags, for example, will make the viewport area adaptable to the device pixel width (typically 320px in the iphone).

<meta name= "viewport" width= "Device-width" >

Before the META tag is used, the page looks like this (using a larger CSS pixel width when calculating the element size):


When the META tag is added, it becomes such as the following (device pixels are used when calculating element dimensions):


A special case of iPhone4

Apple iPhone4 A new display technology, claiming 640px resolution, but it is important to note that the pixel width of the device is still 320px,

Some devices return the screen resolution instead of the device pixel width when media query, which causes inconsistencies in the design of the Web page.

Solutions and Dips

Google introduced a dips (device-independent pixels) concept, web developers only need to deal with dips, how much content the screen can display, without concern about the actual screen resolution, this is a good technical direction, will help eliminate the confusion that new hardware display technology brings to media query programming.


by Iefreer


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.