如何删除背景图片周围的灰色边框?
我在下面的代码中遇到了一个有趣的问题:
I've come across an interesting problem in the following line of code:
<img style="background-image:url(Resources/bar.png); width: 300px; height: 50px;"/>
在Safari中(至少),灰色边框围绕着300x50像素的区域。添加style =border:none;不会删除它。任何想法?
In Safari (at least), a gray border surrounds the 300x50px area. Adding style="border: none;" doesn't remove it. Any ideas?
谢谢。
Mike
Thanks. Mike
所以,你有一个没有src属性的img元素,应用了背景图片样式。
So, you have an img element that doesn't have a src attribute, but it does have a background-image style applied.
我想说,如果您指定了src属性,灰色边框将是图片所在位置的占位符 。
I'd say that the gray border is the 'placeholder' for where the image would be, if you'd specified a src attribute.
如果你不想要一个前景图像,那么不要使用img标签 - 你已经说过,改成一个div解决了问题,为什么不使用该解决方案?
If you don't want a 'foreground' image, then don't use an img tag - you've already stated that changing to a div solves the problem, why not go with that solution?