fontstyle

收藏:0   阅读:23

Style fontStyle 属性


定义和用法

fontStyle 属性设置或返回字体样式是否是 normal(正常的)、italic(斜体)或 oblique(倾斜的)。

语法

设置 fontStyle 属性:

Object.style.fontStyle="normal|italic|oblique|inherit"

返回 fontStyle 属性:

Object.style.fontStyle

描述
normal 默认。字体是 normal(正常的)。
italic 字体是 italic(斜体)。
oblique 字体是 oblique(倾斜的)。
inherit fontStyle 属性的值从父元素继承。


浏览器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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

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


实例

更改字体为斜体:

<html>
<head>
<script>
function displayResult()
{
document.getElementById("p1").style.fontStyle="italic";
}
</script>
</head>
<body>

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

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

</body>
</html>

© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!