Latest web development tutorials

HTML DOM 스타일 글꼴 특성

스타일 객체 참조 스타일 개체

정의 및 사용

글꼴 약식 속성 설정 또는 6 별도의 글꼴 속성까지 돌아갑니다.

이 속성을 사용하면 / 반품을 설정할 수 있습니다 :

  • 글꼴 스타일
  • 글꼴 변형
  • 글꼴 무게
  • 글꼴 크기
  • 라인 높이
  • 글꼴 - 가족

상기 속성은 개별 스타일 속성을 제공 할 수있다. 강력 별도의 속성을 같은 더 나은 제어를 사용하는 것이 좋습니다.

문법

글꼴 속성 설정 :

Object.style.font="[style variant weight size/lineHeight family] or [reserved word]"

위로 글꼴 속성 :

Object.style.font

팁 : 글꼴 속성은 기본값이 없습니다.

描述
style 设置字体样式。
variant 设置文本以小型大写字母字体显示。
weight 设置字体粗细。
size 设置字体尺寸。
lineHeight 设置行与行之间的距离。
family 设置字体系列。
caption 为控件定义字体(比如按钮、下拉列表等)。
icon 定义用于标注图标的字体。
menu 定义菜单中使用的字体。
message-box 定义对话框中使用的字体。
small-caption 定义小型控件中使用的字体。
status-bar 定义窗口状态栏中使用的字体。
inherit font 属性的值从父元素继承。


브라우저 지원

Internet ExplorerFirefoxOperaGoogle ChromeSafari

모든 주요 브라우저 글꼴 속성을 지원합니다.

참고 : IE7 및 이전 버전은 "상속"값을 지원하지 않습니다.IE8은 "상속"지원!의 DOCTYPE을 제공합니다. IE9 지원 "상속".


텍스트 글꼴을 변경합니다 :

<!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>

»시도


스타일 객체 참조 스타일 개체