在网页中缩小单列文本

yur*_*iel 6 html

我正在制作一个非常简单的html网页,仅包含文字.如何缩小单列以使读者更容易阅读?

我希望文本正文大致位于页面的中心并保持对齐,左边和右边的空白边距(大致相等).

Dan*_*ker 6

通过将文本放在带有样式的DIV中来控制宽度:

<DIV style="width: 300px">
    Text goes here.
</DIV>
Run Code Online (Sandbox Code Playgroud)

根据安吉拉在评论中提出的建议,以中心为中心:

<DIV style="width: 300px; margin: 0 auto">
   Text goes here.<br>
    And another line which is much longer.
</DIV>
Run Code Online (Sandbox Code Playgroud)


Mat*_*lor 6

完整的跨浏览器解决方案

html:

<div id="centered"><!-- put your content here --></div>
Run Code Online (Sandbox Code Playgroud)

CSS:

body {
   text-align:center; /* this is required for old versions of IE */
}
#centered {
   width:400px; /* this is the width of the center column (px, em or %) */
   text-align:left; /*resets the text alignment back to left */
   margin:0 auto; /* auto centers the div in standards complaint browsers */
}
Run Code Online (Sandbox Code Playgroud)

就是这样,享受吧!