简体   繁体   English

如何根据屏幕尺寸使用不同尺寸的图像集?

[英]How to use different size image set according the screen size?

I used this code below to use different size image set for different screen size, it works good in firefox and chrome but not wordks in safari.我使用下面的这段代码为不同的屏幕尺寸使用不同尺寸的图像集,它在 firefox 和 chrome 中运行良好,但在 safari 中不适用于 wordks。 Is there any solution?有什么解决办法吗? My code:我的代码:

<picture>
<img src="static/images/content/roni.jpg"
srcset="static/images/content/roni_mobile.jpg 420w,
        static/images/content/roni_landscape.jpg 700w,
        static/images/content/roni_tablet.jpg 1056w,
        static/images/content/roni.jpg 1937w"/>
</picture>

I want solution using html/css/js我想要使​​用 html/css/js 的解决方案

Use Media tag with size and use below code使用具有大小的媒体标签并使用以下代码

.blogpost img {
width:55%;
min-width:220px;
}

.blogpost img {
width:100%;
max-width:600px;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM