是否有一个srcset等效于css的背景图片 [英] Is there a srcset equivalent for css background image

查看:155
本文介绍了是否有一个srcset等效于css的背景图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

img srcset 是否有等效的语法在css background-image 属性中有效?

img with srcset attribute looks like a great way of doing responsive images. Is there an equivalent syntax that works in css background-image property?

HTML

<img src="small.jpg" srcset="medium.jpg 1000w, large.jpg 2000w" alt="yah">

CSS

.mycontainer {
    background: url(?something goes here?);
}


推荐答案

image-set 是等效的CSS功能。我们应该添加等效的srcset功能(根据它们的尺寸定义资源)。

image-set is the equivalent CSS feature. We should add equivalent srcset functionality (defining resources according to their dimensions) to the spec.

目前它只能在Safari,Chrome和Opera中使用 -webkit - 前缀,它只支持 x 描述符。

Currently it's only implemented in Safari, Chrome and Opera with the -webkit- prefix, and it's only support the x descriptors.

这篇关于是否有一个srcset等效于css的背景图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆