Style fontStyle 属性
定义和用法
fontStyle 属性设置或返回字体样式是否是 normal(正常的)、italic(斜体)或 oblique(倾斜的)。
浏览器支持
| 属性 | |||||
|---|---|---|---|---|---|
| fontStyle | Yes | Yes | Yes | Yes | Yes |
语法
返回 fontStyle 属性:
object.style.fontStyle
设置 fontStyle 属性:
object.style.fontStyle = "normal|italic|oblique|initial|inherit"
属性值
| 值 | 描述 |
|---|---|
| normal | 默认。字体是 normal(正常的)。 |
| italic | 字体是 italic(斜体)。 |
| oblique | 字体是 oblique(倾斜的)。 |
| initial | 设置该属性为它的默认值。请参阅 initial |
| inherit | 从父元素继承该属性。请参阅 inherit |
技术细节
| 默认值: | normal |
|---|---|
| 返回值: | 一个字符串,表示元素中文本的字体样式 |
| CSS 版本 | CSS1 |
更多实例
实例
A demonstration of possible values:
var listValue = selectTag.options[selectTag.selectedIndex].text;
document.getElementById("demo").style.fontStyle = listValue;
亲自试一试 »
document.getElementById("demo").style.fontStyle = listValue;
实例
Return the font style of an element:
alert(document.getElementById("demo").style.fontStyle);
亲自试一试 »
相关页面
CSS 教程: CSS Font
CSS 参考手册: font-style 属性
HTML DOM 参考手册: font 属性
❮ Style 对象
