简体   繁体   English

我如何摆脱图像周围的边界?

[英]How I can get rid of border around image?

I can't find a source of problem. 我找不到问题的根源。 I want get rid of border around image. 我想摆脱图像周围的边界。

Problem: http://codepen.io/anon/pen/xeFmt 问题: http//codepen.io/anon/pen/xeFmt

Solution should be cross browser with support of IE8+. 解决方案应该是支持IE8 +的跨浏览器。

Normally it would be: 通常是:

  outline: none;
  border: none;

I suspect CodePen may be adding that so you can see the element or until you add a real src to the tag. 我怀疑CodePen可能会添加该元素,以便您可以看到该元素,或者直到将真正的src添加到标签中。

w3 says SRC is mandatory. w3说SRC是强制性的。

SRC (Source) The SRC attribute specifies the URI for the image to be embedded. SRC(源)SRC属性指定要嵌入图像的URI。 Its syntax is the same as that of the HREF attribute of the tag. 其语法与标记的HREF属性相同。 SRC is mandatory. SRC是强制性的。

Adding any value to the src (even a missing image) makes the border/outline disappear, without having to modify the css. 在src中添加任何值(甚至是丢失的图像)都将使边框/轮廓消失,而无需修改css。

Example: http://codepen.io/anon/pen/eaJum 示例: http//codepen.io/anon/pen/eaJum

Normally it can be achieved by 通常可以通过以下方式实现

border: none;
outline: 0;

But not for the case when actual image is missing, ie not loaded or src attribute is not specified 但不适用于缺少实际图像的情况,即未加载或未指定src属性

正如Romain Braun所建议的那样,将源代码添加到<img/>标签将删除边框。

<img src="http://9to5google.files.wordpress.com/2013/12/google2.jpg" />

Adding an image src="" attribute to it should remove the border but I would also add a border: none; 向其添加图像src =“”属性应删除边框,但我还要添加border: none; to the CSS. 到CSS。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM