我正在使用Angular material-2作为我的前端,
我想为桌面和移动屏幕显示不同的图像
我有这个代码如下所示
最佳答案
我建议你阅读这两篇文章:
> Don’t use
> Native Responsive Images
基本上,如果您尝试以不同的质量级别显示相同的图像,这是一个响应用例,您应该使用< img srcset =“...”>:
如果你想展示非常不同的图像,你可能会谈论艺术方向,在这种情况下,< picture>有道理,因为:
Why can’t we do art-direction with sizes/srcset?
By design,the sizes/srcset syntax takes into account the viewport’s
width as well as the screen’s DPR. Adding art-direction into the same
syntax would have meant that the web developer has to explicitly
specify all the DPR and viewport width combinations in the markup.
That would have made the web developer’s job much more difficult and
would have made the syntax much harder to grasp and significantly more
verbose.
所以语法类似于:
这两种解决方案都有很好的支持:除了IE之外的所有东西,以及回退到常规,非奇特渲染的方法.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。