HTML DOM fontSizeAdjust 属性

定义和用法

fontSizeAdjust 属性设置文本的尺寸。

字体的小写字母 "x" 的高度与 "font-size" 高度之间的比率被称为一个字体的 aspect 值。当字体拥有高的 aspect 值时,那么当此字体被设置为很小的尺寸时会更易阅读。举例:Verdana 的 aspect 值是 0.58(意味着当字体尺寸为 100px 时,它的 x-height 是 58px )。Times New Roman 的 aspect 值是 0.46。这就意味着 Verdana 在小尺寸时比 Times New Roman 更易阅读。

该可为某个元素规定一个 aspect 值,这样就可以保持首选字体的 x-height。

语法:

  1. Object.style.fontSizeAdjust=none|number

可能的值

描述
none 默认。如果此字体不可用,则不保持此字体的 x-height。
number 定义字体的 aspect 值比率。 ### 可使用的公式: 首选字体的字体尺寸 (font-size-adjust 值 / 可用字体的 aspect 值)=可应用到可用字体的字体尺寸 ### 举例: 如果 14px 的 Verdana(aspect 值是 0.58)不可用,但是某个可用的字体的 aspect 值是 0.46,那么替代字体的尺寸将是 14 (0.58/0.46) = 17.65px。

实例

本例调节字体的大小:

  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function adjustFontSize()
  5. {
  6. document.getElementById("p1").style.fontSizeAdjust="0.70";
  7. }
  8. </script>
  9. </head>
  10. <body>
  11.  
  12. <p id="p1">This is an example paragraph</p>
  13.  
  14. <input type="button" onclick="adjustFontSize()"
  15. value="Adjust font-size" />
  16.  
  17. </body>
  18. </html>