Introduction to HTML5 image adaptation

Source: Internet
Author: User

Nowadays, mobile Internet is changing with each passing day, and various mobile devices are emerging one after another. After the first appearance of a Retina screen on iPhone 4, this technology is quickly adopted by most smart mobile devices, it will become increasingly popular.

 

But this also puts forward higher requirements for our Web, because we need to adapt to more complex UI solutions.

Adaptive images will be the next issue to be addressed in responsive network design, because we provide different images for screens with different resolutions, such as iPhone 4s AND iMac. It wastes bandwidth and affects the download speed to provide high-resolution images for low-resolution screens, while providing low-resolution images for high-resolution screens has a significant impact on the experience.

HTML5 specifications are discussing native adaptation support for resolution images. One of the more reliable solutions is as follows:

[Html]
Srcset = "foo-hires.jpg 2x, foo-superduperhires.jpg 6.5x"
Alt = "decent alt text for foo.">
This method introduces a new srcset attribute for the img tag, and uses 2x and 6.5x to tell the browser the adaptive image used for relative resolution of the screen. Note that Media Query is not used.

In addition, the similar image set Scheme (as part of CSS4) has been added to WebKit, for example:

[Html]
Selector {
Background: image-set(url(foo-lowres.png) 1x,
Url(foo-highres.png) 2x) center;
}
The srcset solution is still being discussed and improved, but we can expect a reliable technical solution and standard.

Author: hfahe

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