CSS |文本对齐属性

原文:https://www.geeksforgeeks.org/css-text-justify-property/

CSS 中的文本对齐属性用于将文本对齐设置为对齐。它将单词扩展成一整行。

语法:

text-justify: auto|inter-word|inter-character|none:initial|inherit;

属性值:文本对齐属性值如下所示:

  • auto: It is used to allow the browser to determine which justification property would be better for the given text.

    语法:

    html text-justify: auto;

    例:

    ```html <!DOCTYPE html>        

              text-justify property                        #main {                  border:1px solid green;                 padding-bottom: 6px;             }              #geeks {                  text-align:justify;                 text-justify:auto;             }              h1, h2, h3 {                 text-align:center;             }                               

                GeeksforGeeks         

     

     

    text-justify: auto;

     

                

                 HTML stands for Hyper Text Markup Language.               It is used to design web pages using a markup              language. HTML is the combination of Hypertext              and Markup language.         
              
                               ```

    输出:

  • inter-word: The text is justified by increasing or decreasing the spacing between individual words in a text.

    语法:

    html text-justify: inter-word;

    示例:

    ```html <!DOCTYPE html>        

              text-justify property                        #main {                  border:1px solid green;                 padding-bottom: 6px;             }              #geeks {                  text-align:justify;                 text-justify:inter-word;             }              h1, h2, h3 {                 text-align:center;             }                               

                GeeksforGeeks         

     

     

    text-justify: inter-word;

     

                

                 HTML stands for Hyper Text Markup Language.               It is used to design web pages using a markup              language. HTML is the combination of Hypertext              and Markup language.         
              
                               ```

    输出:

  • inter-character: The text is justified by increasing or decreasing the spacing between individual characters in a text.

    语法:

    html text-justify: inter-character;

    示例:

    ```html <!DOCTYPE html>        

              text-justify property                        #main {                  border:1px solid green;                 padding-bottom: 6px;             }              #geeks {                  text-align:justify;                 text-justify:inter-character;             }              h1, h2, h3 {                 text-align:center;             }                               

                GeeksforGeeks         

     

     

    text-justify: inter-character;

     

                

                 HTML stands for Hyper Text Markup Language.               It is used to design web pages using a markup              language. HTML is the combination of Hypertext              and Markup language.         
              
                               ```

    输出:

  • none: It is used to disable the justification methods used in the text.

    语法:

    html text-justify: auto;

    示例:

    ```html <!DOCTYPE html>        

              text-justify property                        #main {                  border:1px solid green;                 padding-bottom: 6px;             }              #geeks {                  text-align:justify;                 text-justify:auto;             }              h1, h2, h3 {                 text-align:center;             }                               

                GeeksforGeeks         

     

     

    text-justify: auto;

     

                

                 HTML stands for Hyper Text Markup Language.               It is used to design web pages using a markup              language. HTML is the combination of Hypertext              and Markup language.         
              
                               ```

    输出:

支持的浏览器:文本对齐属性支持的浏览器如下:

  • 谷歌 Chrome
  • Internet Explorer 11.0
  • Firefox 55.0
  • 歌剧
  • Safari 10.0.3