【发布时间】:2016-05-31 16:28:45
【问题描述】:
我正在尝试根据设备和屏幕尺寸更改/艺术指导图像,而不仅仅是更改图像的分辨率。
我正在使用<picture> 元素,当我在桌面上调整浏览器大小时它可以正常工作,但在移动设备上却无法正常工作。
目前的代码如下:
<picture>
<source media="(min-width: 950px)" srcset="http://phillipsperfections.com/images/PhillipsPerfections_Home.png">
<img src="http://phillipsperfections.com/images/PhillipsPerfections_Home_500.png" alt=“image”>
</picture>
我了解<picture>并不是所有平台都支持,所以我也尝试了srcset,如下:
<img srcset="http://phillipsperfections.com/images/PhillipsPerfections_Home_500.png 500w,
http://phillipsperfections.com/images/PhillipsPerfections_Home.png 950w"
sizes="100vw”
src="http://phillipsperfections.com/images/PhillipsPerfections_Home_500.png" alt=“image”>
我希望图像始终为 100% 宽度,并在查看 950 像素以下时切换到不同的图像。
我从这里 http://alistapart.com/article/using-responsive-images-now#section3 引用代码,但我错过了什么吗?有人能指出我正确的方向吗?
我的工作站点是http://phillipsperfections.com/。您应该能够查看所有代码的源代码。
非常感谢!
【问题讨论】:
标签: html image mobile responsive-design srcset