简体   繁体   English

元素之间的空白,未知来源

[英]White space between elements, unknown origin

Issue solved 问题解决了

On the bottom, between the last element of the page and the Footer, there is a white space, I'm trying to use Chrome dev tools to track the origin of it, but apparently it's not caused either by the last element and the footer. 在底部,在页面的最后一个元素和页脚之间,有一个空白区域,我正在尝试使用Chrome开发工具来跟踪它的来源,但显然它不是由最后一个元素和页脚引起的。

The only elements in witch it seems the space is coming from, is the body. 女巫的唯一元素似乎是空间的来源,就是身体。 I already canceled any margin or padding of the body element: 我已经取消了body元素的任何边距或填充:

html,body {
margin: 0;
width: 100%;
padding: 0;
}

Compatibility of the website is tested only with Chrome 仅使用Chrome测试网站的兼容性

It's because of the default margin of the heading: 这是因为标题的默认边距:

footer h4 {
  margin: 0;
  padding: 1em 0;
}

It becomes obvious when you use the dev tools to inspect the h4 element. 当您使用开发工具检查h4元素时,这一点很明显。

It is caused by the margin on the h4 inside the footer. 它是由页脚内部h4的边距引起的。 The fenomenon is explained by collapsing margins : collapsing margins解释了这种现象:

Margins collapse between adjacent elements. 边距在相邻元素之间折叠。 In simple terms, this means that for adjacent vertical block-level elements in the normal document flow, only the margin of the element with the largest margin value will be honored, while the margin of the element with the smaller margin value will be collapsed to zero. 简单来说,这意味着对于正常文档流中的相邻垂直块级元素,只有具有最大边距值的元素的边距将被遵循,而具有较小边距值的元素的边距将被折叠为零。

The full explanation can be read here: http://reference.sitepoint.com/css/collapsingmargins 完整的解释可以在这里阅读: http//reference.sitepoint.com/css/collapsingmargins

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

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