简体   繁体   English

从img标签删除边框

[英]remove border from img tag

I am trying to remove a white border i get around img tag. 我正在尝试删除在img标签周围出现的白色边框。

img 
{
    margin:0px;
    padding:0px;
    border : none;
}

<img src="http://upload.wikimedia.org/wikipedia/commons/8/85/Black_300.jpg">         
<img src="http://upload.wikimedia.org/wikipedia/commons/8/85/Black_300.jpg">        

code example at JSfiddle JSfiddle上的代码示例

As you can see 如你看到的 在此处输入图片说明

there is a white margin between the images. 图像之间有白色边距。 How can i remove it ? 我如何将其删除?

The white margin between the images is actually a space character. 图像之间的白色边距实际上是空格字符。 In your code, this is the newline between the images, which is implicitly converted to a space in the browser. 在您的代码中,这是图像之间的换行符,它们在浏览器中隐式转换为空格。

All sequences of whitespace charaters (tabs,newlines,spaces) are in HTML converted to one single space character. 所有空格字符序列(制表符,换行符,空格)都以HTML格式转换为一个空格字符。

You can use this trick to avoid the space character between tags: 您可以使用此技巧来避免标签之间的空格字符:

<img src="img.jpg" alt="My image" width="100" height="100" /><img 
src="img.jpg" alt="My image" width="100" height="100" />   

Remove the whitespace that separates the img tags: 删除分隔img标签的空白:

<img src="http://upload.wikimedia.org/wikipedia/commons/8/85/Black_300.jpg"><img src="http://upload.wikimedia.org/wikipedia/commons/8/85/Black_300.jpg">   

http://jsfiddle.net/aW4Wx/2/ http://jsfiddle.net/aW4Wx/2/

Add float: left; 添加浮点数:左; to the img's css. 到img的CSS。 Like this: 像这样:

img {
    margin:0px;
    padding:0px;
    border : none;
    float: left;
}

See how it works . 看看它是如何工作的

<img src="http://upload.wikimedia.org/wikipedia/commons/8/85/Black_300.jpg"><!--         
--><img src="http://upload.wikimedia.org/wikipedia/commons/8/85/Black_300.jpg">

I am solving in this manner 我正在以这种方式解决

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

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