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


CSS font-variant屬性用法及代碼示例

font-variant屬性用於將所有小寫字母轉換為大寫字母。但是轉換後的大寫字母看起來比原始大寫字母小font-size。

用法:

font-variant:normal|small-caps|initial; 

屬性值:

  • normal:它具有默認值。它指定一個普通的font-size。

    用法:

    font-variant:normal;

    例:



    <!DOCTYPE html> 
    <html> 
      
    <head> 
        <style> 
            h1 { 
                color:green; 
            } 
              
            p.geeks { 
                font-variant:normal; 
            } 
        </style> 
    </head> 
      
    <body> 
        <center> 
            <h1>GeeksForGeeks</h1> 
            <h2>font-variant:normal;</h2> 
            <p class="geeks">GeeksForGeeks.</p> 
            <p>It is a computer science portal for geeks.</p> 
      
    </body> 
      
    </html>

    輸出:

  • small-caps:用於將所有小寫字母轉換為大寫字母。

    用法:

    font-variant:small-caps;

    例:

    <!DOCTYPE html> 
    <html> 
      
    <head> 
        <style> 
            h1 { 
                color:green; 
            } 
              
            p.geeks { 
                font-variant:small-caps; 
            } 
              
            .gfg { 
                font-variant:small-caps; 
            } 
        </style> 
    </head> 
      
    <body> 
        <center> 
            <h1>GeeksForGeeks</h1> 
            <h2>font-variant:small-caps;</h2> 
            <p class="geeks">GeeksForGeeks.</p> 
            <p class="gfg"> 
             It is a computer science  
             portal for geeks. 
            </p> 
      
    </body> 
      
    </html>

    輸出:

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

    用法:

    font-variant:initial;

    例:

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

    輸出:

支持的瀏覽器:CSS font-variant屬性支持的瀏覽器如下:

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

相關用法


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