您的位置:58脚本 > HTML DOM Style fontSize 属性

HTML DOM Style fontSize 属性

2023-05-31 20:32

 HTML DOM Style fontSize 属性

Style fontSize 属性

Style 对象参考手册 Style 对象

定义和用法

fontSize 属性设置或返回文本的字体尺寸。

语法

设置 fontSize 属性:

Object.style.fontSize="value|inherit"

返回 fontSize 属性:

Object.style.fontSize

描述
xx-small
x-small
small
medium
large
x-large
xx-large
把字体的尺寸设置为不同的固定尺寸,从 xx-small 到 xx-large。
smaller 把字体尺寸减小一个相对单位。
larger 把字体尺寸增大一个相对单位。
length 使用 px、cm 等单位定义字体尺寸。
% 定义字体尺寸为父元素字体尺寸的某个百分比。
inherit fontSize 属性的值从父元素继承。


浏览器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主要浏览器都支持 fontSize 属性。

注意:IE7 及更早的版本不支持 "inherit" 值。IE8 只有规定了 !DOCTYPE 才支持 "inherit"。IE9 支持 "inherit"。


实例

实例

更改文本的字体尺寸:

<html>
<head>
<script>
function displayResult()
{
document.getElementById("p1").style.fontSize="xx-large";
}
</script>
</head>
<body>

<p id="p1">This is some text.</p>
<br>

<button type="button" onclick="displayResult()">Change font size</button>

</body>
</html>



Style 对象参考手册 Style 对象
阅读全文
以上是58脚本为你收集整理的 HTML DOM Style fontSize 属性全部内容。
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。
相关文章
© 2024 58脚本 58jiaoben.com 版权所有 联系我们
桂ICP备12005667号-28 Powered by CMS