如何在 HTML 段落中添加空格
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13571706/
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
How to add white spaces in HTML paragraph
提问by Mahmoud Fayez
I want to do something like that
我想做这样的事情
< p >
<p>
This is question 1-------------------(1)
这是问题1-----(1)
This is question 2-------------------(2)
这是问题2--------------------(2)
< / p >
</p>
but replace the dashes with spaces how can I do that.
但是用空格替换破折号我该怎么做。
回答by Rahul Tripathi
You can try it by adding
您可以通过添加来尝试
回答by Marcin Orlowski
If you really need then you can use i.e.
entity to do that, but remember that fonts used to render your page are usually proportional, so "aligning" with spaces does not really work and looks ugly.
如果您真的需要,那么您可以使用 ie
entity 来做到这一点,但请记住,用于呈现您的页面的字体通常是成比例的,因此与空格“对齐”并不能真正起作用并且看起来很难看。
回答by u?nb??s
This can be done easily and cleanly with float
.
这可以通过float
.
Demo: jsfiddle.net/KcdpW
HTML:
HTML:
<ul>
<li>Item 1 <span class="right">(1)</span></li>
<li>Item 2 <span class="right">(2)</span></li>
</ul>?
CSS:
CSS:
ul {
width: 10em
}
.right {
float: right
}?