2009/02/17

font-size, font-size-adjust, font-stretch

font-size | font-size-adjust | font-stretch | line-height
font-size

設定實體字的尺寸。

  1. 絕對尺寸(absolute-size):可設為 xx-small, x-small, small, medium, large, x-large, xx-large,預設值為 medium。在螢幕上,兩級字間差 1.2 倍。
  2. 相對尺寸(relative-size):可設為 larger, smaller,以父元素為準。
  3. 長度:用長度設定字的尺寸,不可為負值。
  4. 百分比:相對於父元素字型尺寸的百分比。
  5. inherit:繼承父元素特徵。

設定字型大小,最佳是用 em, ex 長度單位。第二選是用 px 長度單位。以上單位,在不同瀏覽器的差異比較小。

絕對尺寸

  • 風格用法:

     <style type='text/css'>
    SPAN[style~='font-size:']:after {content:' / '; color:red}
    SPAN[style~='font-stretch:']:after {content:' / '; color:red}
    </style> <span style='font-size: xx-small'>xx-small</span> <span style='font-size: x-small'>x-small</span> <span style='font-size: small'>small</span> <span style='font-size: medium'>medium</span> <span style='font-size: large'>large</span> <span style='font-size: x-large'>x-large</span> <span style='font-size: xx-large'>xx-large</span> 

  • 執行結果:

    xx-small x-small small medium large x-large xx-large

相對尺寸

  • 風格用法:

     <span style='font-size: smaller' >smaller</span> <span>normal</span> <span style='font-size: larger' >larger</span> 

  • 執行結果:

    smaller normal larger

長度尺寸

  • 風格用法:

     <span style='font-size: 16pt'>16pt</span> <span style='font-size: 1pc'>1pc</span> <span style='font-size: 0.5in'>0.5in</span> <span style='font-size: 1cm'>1cm</span> <span style='font-size: 6mm'>6mm</span> <span style='font-size: 1em'>1em</span> <span style='font-size: 2ex'>2ex</span> <span style='font-size: 10px'>10px</span> <span style='font-size: 2ch'>2ch</span> 

  • 執行結果:

    16pt 1pc 0.5in 1cm 6mm 1em 2ex 10px 2ch

百分比尺寸

  • 風格用法:

     <span style='font-size: 60%'>60%</span> <span style='font-size: 80%'>80%</span> <span style='font-size: 100%'>100%</span> <span style='font-size: 120%'>120%</span> <span style='font-size: 140%'>140%</span> 

  • 執行結果:

    60% 80% 100% 120% 140%