我有一个网站有一个带有 src 属性的图像,我想用我自己的图像更改该图像的 src 位置。图像存在于 div 组件中。我无法更改 HTML,正在寻找仅使用 CSS 更改它的方法。
Div 组件:
<div class="application-title">
<img style="margin-top: 3px;height: 45px;" src="image.svgz">
</div>
图片组件(CSS文件):
.application-title IMG
{
float: left;
margin-top: 5px;
margin-right: 10px;
opacity: 1;
margin-left: 0px;
visibility: hidden;
}
最佳答案
你可以使用背景图片
.application-title img {
width:200px;
height:200px;
box-sizing:border-box;
padding-left: 200px;
/*width of the image*/
background: url(http://lorempixel.com/200/200/city/2) left top no-repeat;
}
<div class="application-title">
<img src="http://lorempixel.com/200/200/city/1/">
</div><br />
Original Image: <br />
<img src="http://lorempixel.com/200/200/city/1/">
关于html - 使用 CSS 替换图片 src 位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28832129/