Html <a> 内的 <img> 获得蓝色边框

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2922858/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 03:14:07  来源:igfitidea点击:

<img> inside <a> gets blue border

htmlcssinternet-explorer-8

提问by Mr. Boy

<a href="index.html"><img src="image.png"/></a>

IE8 highlights the image with a blue border. I'm not sure what CSS is relevant here, is it just border? Can I use a single CSS style to turn it off, like:

IE8 以蓝色边框突出显示图像。我不确定这里有什么 CSS 是相关的,它只是边框吗?我可以使用单个 CSS 样式将其关闭吗,例如:

a img {
  ...
}

回答by Sarfraz

Use this css:

使用这个css:

a img {
 border:none;
}

回答by Nick Craver

Yes, you can:

是的你可以:

a img { border: 0; }

You can use 0for 0pxwidth, or nonefor no border overall, same effect...they both work cross-browser.

您可以使用00px宽度,或none为整体无边框,同样的效果......他们都工作跨浏览器。

回答by álvaro González

a img{
    border-width: 0;
}

Find further reference at https://developer.mozilla.org/en/CSS/border

https://developer.mozilla.org/en/CSS/border找到更多参考

I suggest you test your site in other browsers. In this case, you would have noticed that it's not an IE8 issue.

我建议您在其他浏览器中测试您的网站。在这种情况下,您会注意到这不是 IE8 问题。

回答by snickernet

Have you tried setting the image border to 0?

您是否尝试将图像边框设置为 0?

回答by amresh tripathi

You can also use this

你也可以用这个

<img height="20px" border="0" src="image.png" />

However Sarfaraz' answer above is a better approach.

然而,Sarfaraz 上面的回答是一个更好的方法。