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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9140999/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 22:17:16  来源:igfitidea点击:

How can I insert vertical blank space into an html document?

htmlcsswhitespace

提问by DQdlM

I am writing a quiz in htmland I would like to insert a consistent blank vertical space between questions (like one would use vspace{3 cm}in LaTeX).

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

For example:

例如:

<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>

Is there a straight forward way of doing this using just htmland css?

是否有直接使用htmland来做到这一点的方法css

回答by DMCS

Read up some on css, it's fun: http://www.w3.org/Style/Examples/007/units.en.html

阅读一些关于 css 的内容,这很有趣:http: //www.w3.org/Style/Examples/007/units.en.html

<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>

回答by sandeep

write it like this

像这样写

p {
    padding-bottom: 3cm;
}

or

或者

p {
    margin-bottom: 3cm;
}

回答by Scott Biggs

While the above answers are probably best for this situation, if you just want to do a one-off and don't want to bother with modifying other files, you can in-line the CSS.

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

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

回答by narendra singh

i always use this cheap word for vertical spaces.

我总是用这个便宜的词来表示垂直空间。

    <p>Q1</p>
    <br>
    <p>Q2</p>