[英]5px margin/border/padding at the bottom of an image by default?
I've been trying to make 8 images sit tight together, with no gaps inbetween them. 我一直在尝试使8张图像并排放置,彼此之间没有缝隙。 Usually a pretty easy task, but for some reason I can't work out what is happening here. 通常这是一项非常简单的任务,但是由于某些原因,我无法弄清这里发生的事情。
I've reduced the code down to the simplest it can possibly be, but I can't for the life of me work out why this example produces a 5px gap of background: red
. 我已将代码简化为可能的最简单的代码,但是我一生无法弄清为什么此示例产生5px的background: red
间隙background: red
。 Anyone? 任何人?
Codepen: http://codepen.io/patrickwc/pen/phHKk Codepen: http ://codepen.io/patrickwc/pen/phHKk
code (css): 代码(css):
html, body {
margin: 0;
padding:0;
background: red;
}
img {
margin: 0;
padding: 0;
border: 0;
}
code (html): 代码(html):
<img src="http://upload.wikimedia.org/wikipedia/commons/b/b3/Various_grains.jpg">
That's it! 而已! Why isn't the image flush to the bottom of the page? 为什么图像不齐平到页面底部? Please someone put me out of my misery. 请有人使我摆脱痛苦。
Images are inline elements, so like text they have a kind of gutter at the bottom where lowercase letters like y,g etc would hang down. 图像是内联元素,因此像文本一样,它们在底部有一种沟槽,小写字母(如y,g等)会垂下。
Set the image to display:block and you lose the gap. 将图像设置为display:block,您会失去空白。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.