font-size
의 기본값 16px<div style="width:150px;"></div>
<body>
<div style="width:70%"></div>
</body>
font-size
X em 배수
를 계산하여 px로 표현됨기준이 되는 font-size
: 해당 단위가 사용되고 있는 요소(element)의 font-size
. 만약 font-size
가 정의되지 않은 경우 부모의 font-size
를 상속받음.CASE 1
<p style="font-size: 10px; width:20em;">
hello
</p>
width
= 10px 20 = 200px
font-size
: 10px
em 배수
: 20
CASE 2
<p style="width:20em;">
hello
</p>
width
= 16px 20 = 320px
font-size
: 16px (따로 정의되지 않았으므로 브라우저 기본값 16px 상속)
em 배수
: 20
CASE 3
<p style="font-size: 2em; width:20em;">
hello
</p>
width
= 32px 20 = 640px
font-size
: 32px (상속 받은 16px 2 = 32px)
em 배수
: 20
혹은, 16px 2 (font-size
의 em 배수) 20 (width
의 em 배수) = 640px
font-size
X rem 배수
를 계산하여 px로 표현됨.font-size
가 기준이 된다.16px
)을 상속 받음. <p style="width:30rem;">
hello
</p>
width
= 16px 30 = 480px
font-size
: 16px (따로 정의되지 않았으므로 HTML
태그는 브라우저 기본값 16px
을 상속)
em 배수
: 20
https://www.codeguage.com/courses/js/cssom-viewport
vh(viewport height) & vw(viewport width)
1vh
= viewport height의 1%
<p style="height: 30vh;">
hello
</p>
height
=1000px
의30%
= 300px
(viewport
를 1000px X 1000px로 설정)
훌륭한 글이네요. 감사합니다.