📜  CSS | text-align 属性

📅  最后修改于: 2021-08-29 12:13:23             🧑  作者: Mango

CSS 中的text-align属性用于指定元素中文本的水平对齐方式。
句法:

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

属性值:下面列出了 text-align 属性值:

  • left:用于设置文本对齐方式为左对齐。
  • right:用于将文本对齐设置为右对齐。
  • center:用于将文本对齐设置为居中。
  • justify:用于拉伸元素的内容以显示每行相同的宽度。
  • initial:用于设置其默认值。
  • 继承:它是从其父级继承的。

例子:

html


    
        text-align property
        
    
    
        

GeeksforGeeks

        

text-align property

        
            

text-align: left;

            
              The course is designed for students               as well as working professionals to               prepare for coding interviews. This               course is going to have coding questions               from school level to the level needed               for product based companies like Amazon,               Microsoft, Adobe, etc.             
        

        
            

text-align: right;

            
              The course is designed for students               as well as working professionals to               prepare for coding interviews. This               course is going to have coding questions               from school level to the level needed               for product based companies like Amazon,               Microsoft, Adobe, etc.             
        

        
            

text-align: center;

            
              The course is designed for students               as well as working professionals to               prepare for coding interviews. This               course is going to have coding questions               from school level to the level needed               for product based companies like Amazon,               Microsoft, Adobe, etc.             
        

        
            

text-align: justify;

            
              The course is designed for students               as well as working professionals to               prepare for coding interviews. This               course is going to have coding questions               from school level to the level needed               for product based companies like Amazon,               Microsoft, Adobe, etc.             
        
    


输出:

支持的浏览器: text-align 属性支持的浏览器如下:

  • 谷歌浏览器 1.0
  • 浏览器 3.0
  • 火狐 1.0
  • 歌剧 3.5
  • Safari 1.0