如何删除背景图片周围的灰色边框? [英] How do I remove the gray border that surrounds background images?

查看:227
本文介绍了如何删除背景图片周围的灰色边框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在下面的代码中遇到了一个有趣的问题:

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?

这篇关于如何删除背景图片周围的灰色边框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆