當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


CSS text-transform屬性用法及代碼示例


text-transform屬性用於控製文本的大小寫。

用法:

text-transform:none|capitalize|uppercase|lowercase|initial|inherit; 

屬性值:

  • none:它具有默認值。它沒有大寫。

    用法:

    text-transform:none;

    例:



    <!DOCTYPE html> 
    <html> 
      
    <head> 
        <title> 
            CSS text-transform Property 
        </title> 
        <style> 
            h1 { 
                color:green; 
            } 
              
            p.gfg { 
                text-transform:none; 
            } 
        </style> 
    </head> 
      
    <body> 
        <center> 
            <h1>GeeksForGeeks</h1> 
      
            <h2>text-transform:none:</h2> 
            <p class="gfg">GeeksforGeeks</p> 
            <p class="gfg"> 
             It is a computer science portal for geeks. 
            </p> 
    </body> 
      
    </html>

    輸出:

  • capitalize:它用於將每個單詞的第一個字符轉換為大寫。

    用法:

    text-transform:capitalize;

    例:

    <!DOCTYPE html> 
    <html> 
      
    <head> 
        <title> 
            CSS text-transform Property 
        </title> 
        <style> 
            h1 { 
                color:green; 
            } 
              
            p.gfg { 
                text-transform:capitalize; 
            } 
        </style> 
    </head> 
      
    <body> 
        <center> 
            <h1>GeeksForGeeks</h1> 
      
            <h2>text-transform:capitalize:</h2> 
            <p class="gfg">GeeksforGeeks</p> 
            <p class="gfg"> 
             It is a computer science portal for geeks. 
            </p> 
    </body> 
      
    </html>

    輸出:

  • uppercase:它用於將每個單詞中的所有字符轉換或轉換為大寫。

    用法:

    text-transform:uppercase;

    例:

    <!DOCTYPE html> 
    <html> 
      
    <head> 
        <title> 
            CSS text-transform Property 
        </title> 
        <style> 
            h1 { 
                color:green; 
            } 
              
            p.gfg { 
                text-transform:uppercase; 
            } 
        </style> 
    </head> 
      
    <body> 
        <center> 
            <h1>GeeksForGeeks</h1> 
      
            <h2>text-transform:uppercase:</h2> 
            <p class="gfg">GeeksforGeeks</p> 
            <p class="gfg"> 
             It is a computer science portal for geeks. 
            </p> 
    </body> 
      
    </html>

    輸出:

  • lowercase:它用於將每個單詞中的所有字符轉換或轉換為小寫字母。
    用法:
    text-transform:lowercase;

    例:

    <!DOCTYPE html> 
    <html> 
      
    <head> 
        <title> 
            CSS text-transform Property 
        </title> 
        <style> 
            h1 { 
                color:green; 
            } 
              
            p.gfg { 
                text-transform:lowercase; 
            } 
        </style> 
    </head> 
      
    <body> 
        <center> 
            <h1>GeeksForGeeks</h1> 
      
            <h2>text-transform:lowercase:</h2> 
            <p class="gfg">GeeksforGeeks</p> 
            <p class="gfg"> 
             It is a computer science portal for geeks. 
            </p> 
    </body> 
      
    </html>

    輸出:

  • initial:它將屬性設置為其默認值。

    用法:

    text-tansform:initial;

    例:

    <!DOCTYPE html> 
    <html> 
      
    <head> 
        <title> 
            CSS text-transform Property 
        </title> 
        <style> 
            h1 { 
                color:green; 
            } 
              
            p.gfg { 
                text-transform:initial; 
            } 
        </style> 
    </head> 
      
    <body> 
        <center> 
            <h1>GeeksForGeeks</h1> 
      
            <h2>text-transform:initial:</h2> 
            <p class="gfg">GeeksforGeeks</p> 
            <p class="gfg"> 
             It is a computer science portal for geeks. 
            </p> 
    </body> 
      
    </html>

    輸出:

支持的瀏覽器:CSS Text-Transform屬性支持的瀏覽器如下:

  • 穀歌瀏覽器1.0
  • Internet Explorer 4.0
  • Firefox 1.0
  • Opera 1.0
  • Safari 3.5

相關用法


注:本文由純淨天空篩選整理自ManasChhabra2大神的英文原創作品 CSS text-transform Property。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。