DOM atributos de fuente de estilo HTML
Definición y Uso
propiedad abreviada fuente a establecer o devolver hasta seis atributos de fuentes independientes.
Con esta propiedad, se puede establecer / retorno:
- font-style
- font-variant
- font-weight
- font-size
- line-height
- font-family
Estas propiedades se pueden proporcionar atributos de estilo separadas. Aconseja vivamente el empleo de un atributo independiente una mejor capacidad de control tales.
gramática
Configuración de las propiedades de las fuentes:
Object.style.font="[style variant weight size/lineHeight family]
or [reserved word]"
Volver atributos de fuente:
Object.style.font
Consejo: la fuente propiedad tiene ningún valor predeterminado.
值 | 描述 |
---|---|
style | 设置字体样式。 |
variant | 设置文本以小型大写字母字体显示。 |
weight | 设置字体粗细。 |
size | 设置字体尺寸。 |
lineHeight | 设置行与行之间的距离。 |
family | 设置字体系列。 |
caption | 为控件定义字体(比如按钮、下拉列表等)。 |
icon | 定义用于标注图标的字体。 |
menu | 定义菜单中使用的字体。 |
message-box | 定义对话框中使用的字体。 |
small-caption | 定义小型控件中使用的字体。 |
status-bar | 定义窗口状态栏中使用的字体。 |
inherit | font 属性的值从父元素继承。 |
Soporte para el navegador
Todos los principales navegadores soportan los atributos de fuente.
Nota: Internet Explorer 7 y versiones anteriores no son compatibles con el valor "heredar".IE8 sólo proporciona! DOCTYPE apoyado "hereda". apoyo IE9 "hereda".
Ejemplos
Ejemplos
Cambiar la fuente del texto:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult(){
document.getElementById("p1").style.font="italic bold 20px arial,serif";
}
</script>
</head>
<body>
<p id="p1">这是一些文本。</p>
<br>
<button type="button" onclick="displayResult()">修改字体</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult(){
document.getElementById("p1").style.font="italic bold 20px arial,serif";
}
</script>
</head>
<body>
<p id="p1">这是一些文本。</p>
<br>
<button type="button" onclick="displayResult()">修改字体</button>
</body>
</html>
Trate »
Objetos de estilo