简体   繁体   English

CSS-段落之间的额外垂直间距(简单)

[英]CSS - Extra Vertical Spacing Between Paragraphs (Simple)

I realize this is incredibly basic, but I setup a very simple HTML page in Firefox... 我意识到这是非常基础的,但是我在Firefox中设置了一个非常简单的HTML页面...

html {
  margin: 0; padding: 0;
  font-size: 62.5%;
}

p {
  text-align: justify;
  font-family: verdana, sans-serif;
  font-size: 1.6rem;
  width: 90%;
  margin: 0 auto; 
  padding: 1rem 0 1rem 0;
}

Easy enough. 很简单。

However, say I have three paragraphs. 但是,说我有三段。

Above the the first paragraph, there's about 13px worth of space. 在第一段上方,大约有13px的空间。 There's also 13px worth of space underneath the last paragraph. 在最后一段下面还有13px的空间。

Underneath paragraphs 1 and 2 the space isn't collapsing. 在第1段和第2段的下方,该空间没有折叠。 There's about 26px of space - having trouble remembering how to force padding/margins to collapse... 大约有26px的空间-难以记住如何强制填充/边距折叠...

Thanks for any feedback. 感谢您的任何反馈。

Margins collapse when two vertical margins come in contact with each other with the greater margin overrides the other. 当两个垂直边距彼此接触时,边距会崩溃,较大的边距会覆盖另一个边距。 Here is the modified code: 这是修改后的代码:

html {
  margin: 0; padding: 0;
  font-size: 62.5%;
}

p {
  text-align: justify;
  font-family: verdana, sans-serif;
  font-size: 1.6rem;
  width: 90%;
  margin: 1rem auto;
}

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

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