具有完美对齐的HTML段落

时间:2012-11-09 20:56:27

标签: html css alignment paragraph

我想完美地对齐一个段落,以便整个段落位于页面的中心,但左侧和右侧完全对齐。这是一个完美对齐的段落的图片示例: enter image description here

段落看起来像是在某种盒子中,左右两侧完全平直。我如何在css或html中执行此操作?

5 个答案:

答案 0 :(得分:2)

包装器需要通过CSS应用文本对齐:

text-align:justify;
text-justify:inter-word;

一般来说,与“排版”打印应用程序相比,浏览器作为完全对齐的文本做了很多工作。通常,浏览器上的完全对齐使文本HARDER可以读取,通常应该避免使用。

的CSS:

.justify {
    text-align:justify;
    text-justify:inter-word;
}

HTML

<div class="justify"> ...your text...  </div>

答案 1 :(得分:0)

CSS来证明文字的合理性:

style="text-align:justify"

答案 2 :(得分:0)

嗯,单词之间的完美间距是通过证明文本来完成的:

p {
    text-align:justify;
    text-justify:inter-word;
} 

段落在页面中心的位置需要一组共同的规则:

p {
    width: auto;
    margin: 0 auto;
}

边距规则将段落的上边距和下边距设置为0(如果需要,将其修改为足够的间距),并且auto确保左边距和右边距相同。

答案 3 :(得分:0)

<html>
<head>
<style>
div
{
text-align:justify;
text-justify:inter-word;
}
</style>
</head>

<body>
<h1>Perfect Box Type Alignment</h1>
<div>I want to perfectly align a paragraph so that the entire paragraph is in the center of the page but the left and right side are perfectly aligned. Here's a picture example of a paragraph that is perfectly aligned:I want to perfectly align a paragraph so that the entire paragraph is in the center of the page but the left and right side are perfectly aligned. Here's a picture example of a paragraph that is perfectly aligned::</div>
</body>

</html>

请将浏览器窗口调整为完整,以查看其工作原理。

答案 4 :(得分:0)

尝试这样来解决您的问题:

put STYLE code inside external CSS file or <head><style> Write style code here..</style></head>
.proper_alignment_paragraph_class  
{  
  text-align:justify;  
  text-justify:inter-word;  
}
Put this code inside <body></body> tag.  

<div class="proper_alignment_paragraph_class">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>