2

我在尝试用 CSS 替换此图像时遇到问题,我无法访问 html。

http://jsfiddle.net/ES4mH/

<img 
  width="64" 
  height="64" 
  border="0" 
  style="width: 64px; height: 64px;" 
  src="http://www.nitrografixx.com/2013/lock-icon.gif">
</img>

我试过这个,虽然它将图像作为背景添加到当前图像,但它不会替换它。

img[src='http://www.nitrografixx.com/2013/lock-icon.gif'] {
  background: url(http://www.nitrografixx.com/2013/lock_bg.jpg) center !important;  
}
4

2 回答 2

8

try this

<style>
.className{
    content:url("http://www.nitrografixx.com/2013/lock_bg.jpg");
}
</style>
<img class="className"/>
于 2013-05-15T12:29:41.053 回答
3

What you are doing is adding the image to the background of the image element but the image element still has the source attribute pointing to the original image and that's why it's not being removed. You should probably use javscript to remove the element and replace it with something else if that's possible.

于 2013-05-15T12:30:00.270 回答