1、文本内容居中对齐:text-align。
扩展用法:父元素嵌套子元素时,且子元素的宽度小于父元素宽度,使用text-align:center,可以实现子元素的居中对齐。

 1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>文本内容水平居中</title>
 6     <style>
 7         .text-center{
 8             border:3px solid red;
 9             text-align: center;
10             /*text-align: right;*/
11         }
12     </style>
13 </head>
14 <body>
15     <div class="text-center">
16         水平居中对齐
17     </div>
18 </body>
19 </html>
View Code

相关文章:

  • 2022-12-23
  • 2021-12-16
  • 2022-12-23
  • 2021-09-04
  • 2021-11-25
  • 2022-12-23
  • 2022-02-08
  • 2022-12-23
猜你喜欢
  • 2021-11-27
  • 2021-06-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-27
相关资源
相似解决方案