我想设置我的元素的background-image属性,以便背景图像等于元素的“href”属性。 例如:CSS设置元素的背景图像与元素的url
HTML:
<img src="https://www.someimagesite.com/thumbnailimage.jpg" href="https://www.someimagesite.com/largeimage.jpg" width="70" height="70" alt="" class="image">
CSS:(我想也许这样的事情)
img {
width:156px !important;
height:auto !important;
background-image: <href> !important;
}
希望你明白,我想知道。
我正要建议,但一直在寻找为它的支持,这是相当低https://developer.mozilla.org/en/docs/Web/CSS/attr –
@BiepbotVonStirling是的......否则JavaScript只是选项 –