可能的方法:
<pre> ... </pre>
or
style="white-space:pre"
还有别的事吗?
可能的方法:
<pre> ... </pre>
or
style="white-space:pre"
还有别的事吗?
当前回答
在我的例子中,我需要在每段的开头插入,所以我做了下面的事情,它对我很有效,我希望它能帮助到别人
p:first-letter {
margin-left: 20px
}
其他回答
<p style="text-indent: 5em;">
The first line of this paragraph will be indented about five characters, similar to a tabbed indent.
</p>
这个段落的第一行缩进大约5个字符,类似于标签缩进。
有关更多信息,请参见如何使用HTML和CSS创建制表符和空格。
在我的例子中,我需要在每段的开头插入,所以我做了下面的事情,它对我很有效,我希望它能帮助到别人
p:first-letter {
margin-left: 20px
}
User8657661的答案最接近我的需求(跨几行对齐)。然而,我无法让示例代码像提供的那样工作,但我需要如下更改:
<html>
<head>
<style>
.tab9 {position:absolute;left:150px; }
</style>
</head>
<body>
Dog Food: <span class="tab9"> $30</span><br/>
Milk of Magnesia:<span class="tab9"> $30</span><br/>
Pizza Kit:<span class="tab9"> $5</span><br/>
Mt Dew <span class="tab9"> $1.75</span><br/>
</body>
</html>
如果你需要右对齐的数字,你可以改变左:150px到右:150px,但你需要改变基于屏幕宽度的数字(写的数字将是150像素从屏幕的右边缘)。
走一步比@Ivar和风格我自己的自定义标签像这样…对我来说,“tab”更容易记忆和输入。
tab {
display: inline-block;
margin-left: 40px;
}
HTML实现……
<p>Left side of the whitespace<tab>Right side of the whitespace</p>
我的截图…
使用标准的CSS标签大小。
插入一个tab符号(如果是标准tab键,移动光标)按Alt + 0 + 0 + 9
.element {
-moz-tab-size: 4;
tab-size: 4;
}
我的首选:
*{-moz-tab-size: 1; tab-size: 1;}
查看标签大小的代码片段或快速找到的示例。
.t1{ -moz-tab-size: 1; tab-size: 1; } .t2{ -moz-tab-size: 2; tab-size: 2; } .t4{ -moz-tab-size: 4; tab-size: 4; } pre {border: 1px dotted;} <h3>tab = {default} space</h3> <pre> one tab text two tab text </pre> <h3>tab = 1 space</h3> <pre class="t1"> one tab text two tab text </pre> <h3>tab = 2 space</h3> <pre class="t2"> one tab text two tab text </pre> <h3>tab = 4 space</h3> <pre class="t4"> one tab text two tab text </pre>