CSS教程
CSS进阶

CSS text-align

CSS text-align属性用于设置表格单元格框或块元素的水平对齐方式。它与 vertical-align 属性相似,但在水平方向上。

语法

text-align: justify | center | right | left | initial | inherit;

可能的值

justify:通常在报纸和杂志中使用。它会拉伸元素的内容以显示每行的相等宽度。
center:将居中文本居中。
right:用于将文本向右对齐。
left:用于将文本向左对齐。
请参见一个示例,该示例将演示 text-align 属性。

示例

<html>
   <head>
   </head>
<style>
h2{
color: blue;
}
</style>
   <body>
   <h1>Example of text-align proeprty</h1>

   <h2 style = "text-align: center;">
         text-align: center;
      </h2>
      <h2 style = "text-align: right;">
text-align: right;
      </h2>
      <h2 style = "text-align: left;">
          text-align: left;
      </h2>
      <h2 style = "text-align: justify;">
          text-align: justify; To see its effect, it should be applied on large paragraph.
      </h2>
</body>
</html>
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4