HTML DOM fontSizeAdjust 屬性
定義和用法
fontSizeAdjust 屬性設(shè)置文本的尺寸。
字體的小寫(xiě)字母 "x" 的高度與 "font-size" 高度之間的比率被稱為一個(gè)字體的 aspect 值。當(dāng)字體擁有高的 aspect 值時(shí),那么當(dāng)此字體被設(shè)置為很小的尺寸時(shí)會(huì)更易閱讀。舉例:Verdana 的 aspect 值是 0.58(意味著當(dāng)字體尺寸為 100px 時(shí),它的 x-height 是 58px )。Times New Roman 的 aspect 值是 0.46。這就意味著 Verdana 在小尺寸時(shí)比 Times New Roman 更易閱讀。
該可為某個(gè)元素規(guī)定一個(gè) aspect 值,這樣就可以保持首選字體的 x-height。
語(yǔ)法:
Object.style.fontSizeAdjust=none|number
可能的值
值 | 描述 |
---|---|
none | 默認(rèn)。如果此字體不可用,則不保持此字體的 x-height。 |
number |
定義字體的 aspect 值比率。 可使用的公式:首選字體的字體尺寸 * (font-size-adjust 值 / 可用字體的 aspect 值)=可應(yīng)用到可用字體的字體尺寸 舉例:如果 14px 的 Verdana(aspect 值是 0.58)不可用,但是某個(gè)可用的字體的 aspect 值是 0.46,那么替代字體的尺寸將是 14 * (0.58/0.46) = 17.65px。 |
實(shí)例
本例調(diào)節(jié)字體的大小:
<html>
<head>
<script type="text/javascript">
function adjustFontSize()
{
document.getElementById("p1").style.fontSizeAdjust="0.70";
}
</script>
</head>
<body>
<p id="p1">This is an example paragraph</p>
<input type="button" onclick="adjustFontSize()"
value="Adjust font-size" />
</body>
</html>