[英]HTML justify text-align with <pre> tag
I have a problem with the text-align "justify" inside a paragraph with format and fixed width, because I want the paragraph text in HTML to appear totally justified (like it would happen with a MS Word file). 我在带有格式和固定宽度的段落中的text-align“justify”有问题,因为我希望HTML中的段落文本看起来完全合理(就像MS Word文件一样)。 However, this does not happen. 但是,这不会发生。 What I need to modify to achieve it? 我需要修改什么来实现它?
<pre style="color: #000000; font-family: Arial, Helvetica, sans-serif; font-size: medium; width: 500px; text-align: justify;">
I have a problem with the text-align "justify" inside a paragraph with format and fixed width, because I want the paragraph text in HTML to appear totally justified (like it would happen with a MS Word file). However, this does not happen. What I need to modify to achieve it?
</pre>
EDIT: if I replace the <pre>
tag with <p>
tag, my code works properly. 编辑:如果我用<p>
标签替换<pre>
<p>
标签,我的代码可以正常工作。 Can somebody explain me why? 有人可以解释一下为什么吗? Perhaps I am using a wrong use of <pre>
tag. 也许我正在使用<pre>
标签的错误使用。
pre {
text-align: left;
white-space: pre-line;
}
To justify text in <pre>
you need to add white-space: normal;
要为<pre>
文本辩护,你需要添加white-space: normal;
in your styles, but in my opinion this misses the point using the <pre>
tag. 在你的风格,但在我看来,这使用<pre>
标签忽略了这一点。
-- Edit -- - 编辑 -
Instead of <pre>
tag you can just use <div>
with appropriate styles. 您可以使用具有适当样式的<div>
代替<pre>
标签。 It can imitate <pre>
tag very well and is easier to play with. 它可以非常好地模仿<pre>
标签并且更容易玩。
Use tags: 使用标签:
<pre><code>
Your text
Your text
</code></pre>
Remove all spaces preceding your text, all indentation. 删除文本前面的所有空格,所有缩进。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.