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 ¸üÒ×ÔĶÁ¡£
¸Ã¿ÉΪij¸öÔªËØ¹æ¶¨Ò»¸ö aspect Öµ£¬ÕâÑù¾Í¿ÉÒÔ±£³ÖÊ×Ñ¡×ÖÌåµÄ x-height¡£
Óï·¨£º
Object.style.fontSizeAdjust=none|number
¿ÉÄܵÄÖµ
Öµ | ÃèÊö |
---|---|
none | ĬÈÏ¡£Èç¹û´Ë×ÖÌå²»¿ÉÓã¬Ôò²»±£³Ö´Ë×ÖÌåµÄ x-height¡£ |
number |
¶¨Òå×ÖÌåµÄ aspect Öµ±ÈÂÊ¡£ ¿ÉʹÓõĹ«Ê½£ºÊ×Ñ¡×ÖÌåµÄ×ÖÌå³ß´ç * £¨font-size-adjust Öµ / ¿ÉÓÃ×ÖÌåµÄ aspect Öµ£©=¿ÉÓ¦Óõ½¿ÉÓÃ×ÖÌåµÄ×ÖÌå³ß´ç ¾ÙÀý£ºÈç¹û 14px µÄ Verdana£¨aspect ÖµÊÇ 0.58£©²»¿ÉÓ㬵«ÊÇij¸ö¿ÉÓõÄ×ÖÌåµÄ aspect ÖµÊÇ 0.46£¬ÄÇÃ´Ìæ´ú×ÖÌåµÄ³ß´ç½«ÊÇ 14 * (0.58/0.46) = 17.65px¡£ |
ʵÀý
±¾Àýµ÷½Ú×ÖÌåµÄ´óС£º
<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>