【问题标题】:How to use different size image set according the screen size?如何根据屏幕尺寸使用不同尺寸的图像集?
【发布时间】:2017-01-23 11:02:48
【问题描述】:

我使用下面的代码为不同的屏幕尺寸使用不同尺寸的图像集,它在 firefox 和 chrome 中运行良好,但在 safari 中不适用 wordks。有什么解决办法吗?我的代码:

<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>

我想要使用 html/css/js 的解决方案

【问题讨论】:

    标签: jquery html css image


    【解决方案1】:

    使用具有大小的媒体标签并使用以下代码

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

    【讨论】:

    • 有没有使用js的解决方案?我有 4 组不同大小的图像。我想将它用于台式机、平板电脑、移动设备和移动环境。
    • 你的例子不是一个完整的答案。如果我按原样使用它,它不会解决 OP 的原始问题
    猜你喜欢
    • 2015-02-28
    • 2011-06-15
    • 1970-01-01
    • 2015-08-28
    • 1970-01-01
    • 2017-03-28
    • 2018-12-19
    • 2011-04-21
    • 1970-01-01
    相关资源
    最近更新 更多