我正在使用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.
所以语法类似于:
原文链接:https://www.f2er.com/js/429267.html