JavaScript

[DOM_Style] JS - fontStyle 속성 - 글자모양 (= font-style속성 = 글씨체모양 = 글씨모양 = 글자모양 = 서체모양 = 글꼴모양 = 폰트스타일) + (이탤릭체, 기울임체) (상속 O)

fontStyle 예제 

 

<p id="hz">홈짱닷컴 Homzzang.com</p>


<button type="button" onclick="homzzang()">클릭</button>

 

<script>

function homzzang() {

  document.getElementById("hz").style.fontStyle = "italic";

}

</script>

 

결과보기

 

 

fontStyle 정의 

 

글자 스타일 반환/설정.

 


 

1.

기본값: normal

 

2.

모든 브라우저 지원.


 

 

fontStyle 구문 

 

[반환] 

object.style.fontStyle

 

[설정]

object.style.fontStyle = "속성값"

 


 

[속성값]

 

normal
일반 폰트 (기본값)
 
italic
이탤릭체
 
oblique
기울임체
 
initial

이 속성의 기본값으로 설정.

 
inherit

부모 요소의 스타일을 상속 

 


 

[반환값]

요소에서 텍스트의 글꼴 스타일을 나타내는 문자열.

 

 

 

fontStyle 예제 - select 선택값으로 폰트스타일 지정

 

<p id="hz">홈짱닷컴 Homzzang.com</p>


<select onchange="homzzang(this);" size="3">

  <option>normal</option>

  <option>italic</option>

  <option>oblique</option>

</select>

 

<script>

function homzzang(st) {

  var styleValue = st.options[st.selectedIndex].text;

  document.getElementById("hz").style.fontStyle = styleValue;

}

</script>

 

결과보기

 

 

fontStyle 예제 - 폰트스타일 반환

 

<p id="hz" style="font-style:italic;">홈짱닷컴 Homzzang.com</p>


<button type="button" onclick="homzzang()">클릭</button>

 

<script>

function homzzang() {

  alert(document.getElementById("hz").style.fontStyle);

}

</script>

 

결과보기

 


분류 제목
DOM_Style JS - font 속성 ★ - 글자스타일종합 (= font속성 = 글씨체 = 서체 = 글꼴 = 폰트속성, 상…
DOM_Style JS - fontFamily 속성 ★ - 폰트 종류 설정/반환. (= 글꼴 종류 = fontFamily속성 …
DOM_Style JS - fontSize 속성 - 글자크기 (= 폰트크기 = fontSize속성 = 폰트사이즈 속성)
DOM_Style JS - fontStyle 속성 - 글자모양 (= font-style속성 = 글씨체모양 = 글씨모양 = 글자…
DOM_Style JS - fontVariant 속성 - (소문자/보통) 크기의 대문자로 설정/반환.
DOM_Style JS - fontWeight 속성 - 글자굵기 (= font-weight속성 = 폰트굵기 = 글씨체굵기 =글…
DOM_Style JS - fontSizeAdjust -
DOM_Style JS - fontStretch -
DOM_Style JS - hangingPunctuation -
DOM_Style JS - height 속성 - 요소 높이 설정/반환 (= height속성 = 하이트속성) ※ 요소 세로길이 …
DOM_Style JS - hyphens -
DOM_Style JS - icon -
DOM_Style JS - imageOrientation -
DOM_Style JS - isolation -
DOM_Style JS - justifyContent 속성 - flex 항목 세로 정렬 설정/반환 (= justifyConte…
7/13
목록
 홈  PC버전 로그인 일본어
그누앞단언어
그누뒷단언어
그외코딩언어
그누보드
제작의뢰
Q&A
커뮤니티 2
웹유틸
회원센터
홈짱닷컴 PC버전 로그인