Picturefill + picture Tags for compatibility great responsive pictures Adaptive screen size

Source: Internet
Author: User

Polyfill It's a thing to do with the browser compatibility issue, the <picture></picture> tag that's used, not all browsers support it, for better compatibility, here's the thing. It can provide some alternative ways when the browser does not support, for the responsive picture, the famous Picturefill Library can implement a strong compatibility of ' responsive ' picture, for browsers that do not support pictures, it will use JS to get the srcset behind the settings, and then decide what kind of image to output

How to use

Introduction of JS file (available for download from cdnjs.com)

<src= "Js/vendor/picturefill.min.js"></script  >

Take a look at the introduction of pictures using the Picture property

< Picture>       <SourceSrcset= "Img/ad001-l.png"Media= "(min-width:50em)">       <SourceSrcset= "Img/ad001-m.png"Media= "(min-width:30em)">       <imgsrc= "Img/ad001.png"alt= "2015 Annual report"></ Picture>

The code above means that

Above 800px (normal screen and large screen) use large image ad001-1.png,

481px-800px (medium screen) uses medium picture ad001-m.png,

Less than or equal to 480px (small screen) when the default picture is used Ad001.png

The effect is as follows

Big screen

Medium screen

Small screen

Picture can have a lot of source, the media query defines the screen size to load, Srcset is the corresponding load address (50em = 50*16 =800px);

The last word of the IMG tag is the default loaded image.

Picturefill + picture Tags for compatibility great responsive pictures Adaptive screen size

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.