[css] How UNITS are converted from relative to absolute(px)

2018. 7. 13. 22:40・Frontend/HTML, CSS

#1 Declaration

 

① Declared value

② Cascaded value

③ Specified value

④ Computed value

⑤ Used value (final calculation)

⑥ Actual value

 

root font-size -> 16px(Browser default)

section font-size -> 1.5rem -> computed: 16px * 1.5 = 24px(Inheritance)

 

 

#2 Inheritance

 

    Example(x) How to convert to pixels Result on pixels
   % (font)  150%  x% * parent's computed font-size(16px)  24px
   % (length)  10%  x% * parent's computed width(1000px)  100px
font-based  em (font)  3em  x% * parent's computed font-size(24px)  72px 
 em (length)  2em  x% * current element computed font-size(24px)  48px
   rem  10rem  x% * root computed font-size(16px)  160px 
viewed-based  vh  90vh  x * 1% of viewport height  90% of the current viewport height 
 vw  80vw   x * 1% of viewport width  80% of the current  viewport width

 

 

  • Each property has an initial value, used if nothing is declared(and if there is no inheritance)
  • Browsers specify a root font-size for each page(usually 16px)
  • Percentages are relative value are always converted to pixels
  • Percentages are measured relative to their parent's font-size, if used to specify font-size
  • Percentages are measured relative to their parent's width, if used to specify lengths
  • em are measured relative to their parent font-size, if used to specify font-size
  • em are measured relative to the current font-size, if used to specify length
  • rem are always measured relative to the document's root font-size
  • vh and vw are simply percentage measurements of the viewport's height and width

 

 

저작자표시 비영리 (새창열림)

'Frontend > HTML, CSS' 카테고리의 다른 글

[Sass] Architect : the 7 - 1 pattern  (0) 2018.07.20
[css] the problem of setting the font-size to pixels of body element  (0) 2018.07.15
[css] Inheritance In CSS  (0) 2018.07.13
[css] How CSS Works? and what is Specificity?  (0) 2018.07.12
px, %, rem, em 변환과정  (0) 2017.12.27
'Frontend/HTML, CSS' 카테고리의 다른 글
  • [css] the problem of setting the font-size to pixels of body element
  • [css] Inheritance In CSS
  • [css] How CSS Works? and what is Specificity?
  • px, %, rem, em 변환과정
dev.hyejin
dev.hyejin
  • dev.hyejin
    혜진의 개발자 성장블로그
    dev.hyejin
  • 전체
    오늘
    어제
    • 분류 전체보기 (89)
      • 2024 데브캠프 (2)
      • 회고 (1)
      • 이슈해결 (3)
      • 기초학습 (13)
      • Frontend (20)
        • JavaScript (3)
        • Git, GitHub (3)
        • HTML, CSS (14)
      • Backend (8)
        • Database (4)
        • Java (4)
      • CS (16)
        • Network (10)
        • Algorithm (6)
      • Eng (16)
      • Tips (5)
  • 인기 글

  • 태그

    절대경로
    GitHub
    border-box
    box-sizing
    시간복잡도
    객체
    런타임
    점근성능
    ER모델
    상대경로
  • hELLO· Designed By정상우.v4.10.3
dev.hyejin
[css] How UNITS are converted from relative to absolute(px)
상단으로

티스토리툴바