在 html 的同一行中有空格

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11135368/
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-29 01:11:05  来源:igfitidea点击:

Having space in the same line in html

html

提问by lakesh

I would like to have some space between the same line.. I know there are elements such as <br>, <p>and others. Instead of using these, I would like to add little space between the characters...

我想在同一行之间有一些空间.. 我知道有诸如<br>, <p>和其他元素。而不是使用这些,我想在字符之间添加一点空间......

Example Code:

示例代码:

 <strong>
   New? Register here!
</strong>
 <span>
    Register
 </span>

I would like to have some space between them. How can do this in HTML?

我想在他们之间留一些空间。如何在 HTML 中做到这一点?

回答by flyx

In your example, you may apply some CSS rules, e.g.:

在您的示例中,您可以应用一些 CSS 规则,例如:

span {
    margin-left: 5em;
}

Or inline:

或内联:

<strong>
   New? Register here!
</strong>
<span style="margin-left: 5em;">
    Register
 </span>

回答by Stefan Haustein

Add &nbsp;for a space character that will not be collapsed.

添加&nbsp;一个不会折叠的空格字符。

Alternatively, add a span with a certain width, e.g.

或者,添加具有特定宽度的跨度,例如

<span style="width:50px;display:inline-block"></span>

(I think the element needs to be of display type inline-blockto respect block properties such as padding, border, margin, width etc.).

(我认为元素需要是显示类型inline-block以尊重块属性,例如填充、边框、边距、宽度等)。

回答by iMom0

use this instead:

改用这个:

<strong>
   New?&nbsp;Register&nbsp;here!
</strong>
<span>
   Register
</span>

回答by Bishnu Paudel

Just add ' br/ ' before closing strong tag

只需在关闭强标签之前添加 'br/'

回答by U.P

&nbsp;for space character.

&nbsp;为空格字符。

Wonder why you need that.

想知道你为什么需要那个。