gpt4 book ai didi

html - 使用 css 替换图像(在 标签中)

转载 作者:太空狗 更新时间:2023-10-29 16:51:50 26 4
gpt4 key购买 nike

我有以下 html:

<div class="A">
<img src="image1.png" width="100px" height="100px"/>
</div>

在我的媒体查询 css 样式表中,我想用另一个图像 (image2.png) 替换该图像。

我需要写什么css代码?

我尝试了以下方法:

.A img
{
background:url("image2.png") no-repeat;
}

但这似乎不正确?

最佳答案

如果您使用的是 CSS3,那么 content 就是答案:

.A img
{
content: url("image2.png");
}

关于html - 使用 css 替换图像(在 <img/> 标签中),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12142386/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com