两种方法实现响应式图片:
<picture>
<img>
在该两个标签中使用srcset
和sizes属性,如:
配合的css如下
article{ margin: 0 auto; max-width: 700px; }@media (max-width: 500px) { img {width: 250px } }
转载摘抄翻译自:
- http://css-tricks.com/video-screencasts/133-figuring-responsive-images/?utm_source=dlvr.it&utm_medium=twitter
- http://scottjehl.github.io/picturefill/
- http://martinwolf.org/2014/05/07/the-new-srcset-and-sizes-explained/
- http://ericportis.com/posts/2014/srcset-sizes/