Compatible processing of retina New iPad and general resolution iPad page, newipad

Source: Internet
Author: User

Compatible processing of retina New iPad and general resolution iPad page, newipad
I. Experience Sharing


Even if it is not fruit powder, you should know that one of the major differences between iPad2 and the new iPad is the display resolution. The new iPad display is called the retina display. Its device resolution ratio (for more information, click here) is twice that of ipad2. -IPad mini is also a normal resolution ratio.


IPad2 and the new iPad display a page at the same time. The width is 1024 pixels. What is the difference? -- Each pixel of the new iPad actually has four times the normal pixel, as shown below (©Smashingmagazine ):


The pixel value (px) We set using CSS is a common pixel, or a standard pixel.


Therefore, for a 200x200 image, we set the following CSS:

Html code
  • Img {
  • Width: 200px;
  • Height: 200px;
  • }
  • img {    width: 200px;    height: 200px;}


    In iPad2 or Mini iPad, images are normally displayed. However, in New iPad, one CSS pixel actually has four bitmap pixels, and one is divided into four, obviously not enough, only colorApproximate SelectionTherefore, the image is blurred (©Smashingmagazine )!


    Therefore, for high-definition display of images on the Retina screen, the original size of the images we need cannot be 200x200 pixels, but 2 times the height, that is, 400x400 pixels, the CSS pixel limit is still:

    Html code
  • Img {
  • Width: 200px;
  • Height: 200px;
  • }
  • img {    width: 200px;    height: 200px;}


    At this point, the Retina screen displays OK (non-Retina screen images are compressed-pixel sampling is reduced-A waste of resources !) (©Smashingmagazine ):


    Therefore, different pixel resolution ratios on different iPad platforms are the most compatible!


    Recently, a pad-related project is coming to an end. Just like this, there is a big gap between the product and the comments. The difference lies not in the technical implementation ...... After all, it is not driven by excellent parties ...... (Don't hold back, let's talk about it ~) For example, when a railway was built, the line was quickly planned. As a result, granite geology was found during road construction. The biggest trade-off method was to modify the design route. The result was a slogan: the workers, I believe in your technology. Everyone is not afraid of difficulties and obstacles. Come on together ...... All of us understand the results --It is silly to use technology to make up for design defects!


    There are a lot of things that can't be done by one person. Let's do something practical: fishing, sharing some technical experiences, maybe more valuable, haha!


    Ii. Design Drawings


    The design must be designed for high definition, that is, the width is 2048 pixels. Why? History is forward, and backward compatibility is king and trend.


    When determining the CSS pixel size of an element, the design size divided by 2 is the exact value. For example, on the design drawing:


    Iii. CSS Image Generation


    Obviously, some rounded corners and gradient are implemented using CSS3. In this way, both the high-definition screen and the ordinary screen are very good, especially on the New iPad!


    For example, the text in the voucher icon above is text, and the subsequent gradient and rounded corner are all CSS implementations. The Code is as follows:

    Html code
  • . Priv_icon_coupon {
  • Display: inline-block;
  • Width: 70px;
  • Height: 70px;
  • Border-radius: 0.1em;
  • Background-image:-webkit-gradient (linear, 0 0, 0 bottom, from (# EF137A), to (# 9C117A ));
  • Font: bold 50px/64px "";
  • Color: # fff;
  • Text-align: center;
  • Text-shadow: 0 1px rgba (0, 0,. 5 );
  • }
  • . Priv_icon_coupon {display: inline-block; width: 70px; height: 70px; border-radius: 0.1em; background-image:-webkit-gradient (linear, 0 0, 0 bottom, from (# EF137A), to (# 9C117A); font: bold 50px/64px ""; color: # fff; text-align: center; text-shadow: 0 1px rgba (0, 0, 0 ,. 5 );}


    Html code
  • <Span class = "priv_icon_coupon"> coupon </span>
  • <Span class = "priv_icon_coupon"> coupon </span>


    As shown in the following figure, the New iPad displays very delicate results in the Chrome browser. (If I don't get it, I just want to figure it out. I can't take a picture of it on my Nokia phone ~~)


    Or the following graphic effects (in Chrome) can be implemented using CSS-No worries about compatibility issues such as IE!


    4. Customize the Icon Fonts)


    Not all images can be generated using CSS, such as many small solid color icons. At this point, we can use another technology: Custom icon font!


    I made the product using the free open source icon font of IcoMoon. Select the appropriate small icons based on the design drawing to generate a Custom font. For more information, click here to view details!


    Someone once complained that the website is too new to be used. In fact, you don't have to worry about it. First, on the same modern browser, the font you selected will be stored locally, and your previous selections will be automatically displayed the next time you open the browser, even if the local information is removed, you can edit and generate a new SVG font file by importing it!


    For all the icon fonts I used in the project:


    The related CSS is as follows:

    Html code
  • /* Custom fonts */
  • @ Font-face {
  • Font-family: ico;
  • Src: url (/B/pad/font/icomoon. eot );
  • Src: url (/B/pad/font/icomoon. eot? # Iefix) format ('embedded-opentype '),
  • Url (/B/pad/font/icomoon. woff) format ('woff '),
  • Url (/B/pad/font/icomoon. ttf) format ('truetype '),
  • Url (/B/pad/font/icomoon. svg # icomoon) format ('svg ');
  • }
  • /* custom fonts */@font-face {    font-family: ico;    src: url(/b/pad/font/icomoon.eot);    src: url(/b/pad/font/icomoon.eot?#iefix) format('embedded-opentype'),        url(/b/pad/font/icomoon.woff) format('woff'),        url(/b/pad/font/icomoon.ttf) format('truetype'),        url(/b/pad/font/icomoon.svg#icomoon) format('svg');}


    Of course, traditional web Development@font-faceThe related code is different from the above (you don't need to worry about the earlier version of IE browser). For details, see my previous article "CSS3 @ font-face achieves a triangular effect with controllable color size.


    The advantage of using a Custom font image is that no matter how high your screen pixel ratio is, my image is fine and smooth, and the higher the pixel ratio, the better the effect! Therefore, there is no need to worry about the screen resolution difference between iPad2 and iPad3!


    For example, in the Chrome browser, the page proportion is quite large with the mouse, and the effect is smooth:


    5. Use SVG background


    I have not used the SVG background in this project, but I have used it in the previous mobile phone project. similar to this, it can solve the compatibility problem between the high-definition iPhone and the general iPhone, for details, refer to the preceding article "SVG features, support, and some practical problems ".


    The following is an example of the boundary effect:


    Click here to view the SVG file: circle. svg


    This SVG file is self-drawn. If you want to create an SVG file by yourself, see here.


    6. Backward compatibility under background-size


    Some small icons, designers make them gradient, border, and irregular. At this time, the Custom font is not fixed (only partial text gradient is supported ), SVG is also uncertain (its own drawing capability is limited, 55555555), so we have to use traditional images.


    At this time, the even strategy is like this. The original size of the HD image is extracted from these small icons, and the background-size is used to limit the size, so the HD devices are given priority; because they all belong to small icons, the wasted size is limited. In terms of trade-offs, it is the best strategy.


    For example, the following design results:


    The image information is as follows:


    It can be seen that the height is only the original height on the design drawing. In actual CSS processing, the size is limited to 1/2. The Code is as follows:

    Html code
  • Star,. star_in {
  • Background: url(star.png) repeat-x;
  • Background-size: 14px 30px;/* Raw size 28x60 */
  • }
  • ...
  • Star,. star_in {background: url(star.png) repeat-x; background-size: 14px 30px;/* Raw size 28x60 */}...


    So, in the end, the high-definition display under the HD new iPad, the effect is amazing; the ordinary pad is compressed by 1/2, the effect is also good, it is clear!


    Of course, if you have enough energy to pursue perfection, you can use CSS for precise control, for example:

    Html code
  • @ Media only screen and (-Webkit-min-device-pixel-ratio: 1.5 ){
  • /* When the pixel ratio of the device is no less than 1.5 ...*/
  • }
  • @ Media only screen and (-Webkit-min-device-pixel-ratio: 1.5) {/* When the pixel ratio of a device is not less than 1.5 ...*/}


    7. Common img images that are most difficult to process


    Display images are the most difficult to process.


    For example, for a restaurant image, CSS limits the pixel width to 480x320. If we directly display an image of 480x320 pixels, the image is equivalent to 2 times the stretch effect-blur! If you restrict HD 960*640 images, Oh, my gaga! This increases the image size by 4 times. That is to say, on average iPad, 3/4 of the image traffic is redundant and wasted, the key display effect is not as good as 480*320 pixels! How can we weigh and play games !?


    Theoretically, the best practice is to display images of different sizes on different screen devices. The procedure is as follows:


  • You can setdevicePixelRatioThe size of the notification in the background to achieve the perfect HTML output; or the specific URL displayed in the image is controlled using JavaScript, such as Html code.
  • Html code 
  • Var eleImg = $ ("img"), ratio = window. devicePixelRatio;
  • EleImg. attr ("src", eleImg. attr (ratio> 1.5? "Data-url2": "data-url "));
  • var eleImg = $("img"), ratio = window.devicePixelRatio;eleImg.attr("src", eleImg.attr(ratio  > 1.5? "data-url2": ""data-url"));

    However, the above practice is just a theoretical practice. In fact, if you fully follow the above practices, you will encounter many obstacles-resources, cooperation, implementation, and final results! To put it bluntly, it is a great deal of work. In the end, it may still be thankless-the boss is roaring with a high-definition iPad: Why is the loading of images on this waterfall stream page so slow !!


    Or that sentence,Everything lies in the balance!


    People commented on the iPad high-definition version. The dishes on the restaurant details page were blurred (I cannot figure them in my eyes ~); As you can see, public comments may choose the speed, rather than the quality of the picture (because there may be hundreds of special dishes here-although dynamic loading is used )!


    However, some special images can be compatible.


    For example, Google static images (with scaling) at the restaurant location ):


    If you do not consider the new iPad and other Retina screen devices, you can simply use the following Code:

    Html code


    The following results (not ):


    However, the figure above is blurred on the latest iMac or on the new iPad. It is very incompatible with the delicate text and icons next to it. We need to perform special processing.


    The new iPad is just twice the size.size=300x210We changed itsize=600x420And then scale the scale.zoom=12You can increase it by a bit, for examplezoom=16.


    Therefore, the HTML code for the new iPad is:

    Html code


    The following results (not ):


    As for how to display different pictures on different screens, there are a lot of ways for you to use different methods.


    For example, my restaurant information (including static Map Locations) is loaded using Ajax load HTML. Therefore, when I request Ajax, send the pixel ratio of the device on the iPad to devicePixelRatio to the background, and send other things to the background for judgment and output!


    I am not very familiar with static map research. There may be some improper solutions here. I would like to thank you for your correction!


    8. Oh, this is the conclusion.


    The content of this article is actuallyNot only for iPad page creationAnd mobile phones. With the increasing popularity of retina desktop display (for example, 2012 iMac uses a "retina" screen, some other monitors will follow suit in the future ~~), Our traditional web page development will also face new challenges-not only processing different display resolutions, but also processing different device pixel ratios!


    It seems that Apple has a wide range of things to subvert, so it cannot be spared.


    The development is fast, and it is not easy to stop. Opportunities and challenges coexist. Come on, Arang!

    Ipad3 the new ipad resolution compatibility

    I bought a New iPad in early June. The screen effect is very good. The most important thing is that you no longer need to enlarge the webpage, so you can use the original size to make it clear. This is easy and convenient.

    In addition, the camera is indeed a lot better, and the current camera and iPhone 4 are a class, this time I went to Germany to take a lot of photos, very convenient and good effect. I don't know much better than iPad 2.

    If the software is not scaled down, it will automatically zoom in. the iPad 2 version shows the same effect as iPad 2 on the New iPad. However, more and more software is now available for the New iPad, which is very effective.

    Which of the following products has the highest resolution for Apple?

    Compared with iPad2 and ipad, ipad3 doubles the resolution, which is called a Retina screen. It looks really good.
    Apple products include laptops, MacOS, desktops, imac, itouch, iPhone, and ipod.
    Resolution is of course the best for retina screens.
    Ipad3 and iPad4 have the same resolution, 2048*1536
    The only difference is that ipad3 uses A5x processor, ipad4 uses A6x processor, and iPad4 replaces the data interface with lightning. (Who told you that ipad4 has the highest resolution ?)

    Related Article

    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: 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.