With the gradual popularization of Retina screens , there is a growing need for images to be adapted in the web. How to make the image in a magnified twice times the Retina screen display is still clear, once plagued the web developer, fortunately CSS3 and HTML5 have been focused on changing this situation. So what exactly is a responsive picture?
What is a responsive picture?
response picture refers to: user agents load different types of pictures based on the resolution of the output device, without causing a waste of bandwidth. At the same time, when changing the output device type or resolution, the corresponding type of picture can be loaded in time. UI Front-end Framework latest masterpiece! Prize Probation!
CSS Responsive Pictures
For many IOS developers, it may be a little strange to fit the retina screen, the traditional CSS3 implementation is by loading a picture with a wide height of twice magnification, and then reducing the size of the background image by a Media Queries by one-fold "background-size : 50% 50%;", for example: UI front-end frame latest masterpiece! Prize Probation!
. mod. HD h3 {Background-image:url (/uploads/allimg/130402/013j45508-1.png);/* Normal screen *//* ———— Retina ———— */@media only SC Reen and (-O-MIN-DEVICE-PIXEL-RATIO:2/1),/* Opera */only screen and (min–moz-device-pixel-ratio:2),/* Firefox 1 6 before */only screen and (-webkit-min-device-pixel-ratio:2),/* WebKit */only screen and (min-resolution:240dpi), /* Standard */only screen and (MIN-RESOLUTION:2DPPX)/* Standard */{.MOD. HD h3{background-image:u RL (http://img02.taobaocdn.com/tps/i2/T1t9wzXlxXXXczY8cm-212-310.png); background-size:106px 155px;}}
The contrasting effect of two pictures:
There are some issues to be aware of when making @2x pictures:
If similar is the text content of the picture, do not directly from the large picture to zoom to small pictures, so that the text effect will be somewhat distorted, this is the problem of Photoshop rendering. You should adjust the font size and then re-typeset. Can directly see the effect of the first page of the UI front-end framework of the latest masterpiece! Prize Probation!
The blue box is the effect of directly scaling the image size, the red box is the effect of changing the font size from number 32nd to number 16th.
HTML5 Responsive Picture
CSS Image-set solves the problem of the response of the background image, but what about the IMG element in HTML? As I helpless, a draft of HTML5 was presented in November 2011 @brucel :
<picture alt= "" ><source src=hires.png media= "min-width:800px" ><source src=midres.png media= " min-width:480px "><source src=lores.png><!– unsupported Browser demotion processing –></ Picture>
At the same time, other ideas have sprung up . As of this time, the most recent update was January 7, 2013, the canonical example:
<picture width= "500″height=" 500″><source media= "(min-width:45em)" srcset= "Large-1.jpg 1x, large-2.jpg 2x" ><source media= "(min-width:18em)" srcset= "Med-1.jpg 1x, med-2.jpg 2x" ><source srcset= "Small-1.jpg 1x, Small-2.jpg 2x "><p>accessible text</p></picture>
You can see that the "srcset" property here is similar to Image-set, and usually the resources inside the Srcset are fallback features, which means that the first image resource cannot be loaded and can skip loading the back-up resources. But Apple's Eoconnor proposed the following: UI front-end Framework latest masterpiece! Prize Probation!
Admittedly, any new standard of the proposed, there will be a variety of different voices, it is good, as the end of the Web site developers are not too concerned about the implementation of the syntax.
HTML5 and CSS Responsive pictures