如何在 HTML 文档中插入垂直空格?

新手上路,请多包涵

我正在用 HTML 编写一个测验,我想在问题之间插入一个一致的空白垂直空间(就像在 LaTeX 中使用 vspace{3 cm} 一样)。

例如:

 <html>
  <body>
    <p>
     This is the first question?
      <!-- This is where I want about 3 cm of space -->
    </p>
    <p>
     This is the second question?
     <!-- This is where I want about 3 cm of space -->
    </p>
  </body>
</html>

是否有仅使用 HTML 和 CSS 的直接方法来做到这一点?

如何在 HTML 文档中插入垂直空格?

原文由 DQdlM 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 729
2 个回答

阅读一些关于 CSS 的内容。这很有趣: CSS:em、px、pt、cm、in……

 <style>
  .bottom-three {
     margin-bottom: 3cm;
  }
</style>

<p class="bottom-three">
   This is the first question?
</p>
<p class="bottom-three">
   This is the second question?
</p>

原文由 DMCS 发布,翻译遵循 CC BY-SA 4.0 许可协议

虽然前面的答案可能最适合这种情况,但如果您只想一次性完成并且不想费心修改其他文件,则可以内联 CSS。

 <p style="margin-bottom:3cm;">This is the first question?</p>

原文由 SMBiggs 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
logo
Stack Overflow 翻译
子站问答
访问
宣传栏