Responsive Web Design

κΉ€_λ¦¬νŠΈλ¦¬λ²„Β·2020λ…„ 9μ›” 21일
0

CSS

λͺ©λ‘ 보기
3/3

ViewPort

πŸ€” μ •μ˜

  • μ‚¬μš©μžκ°€ μ›ΉνŽ˜μ΄μ§€μ—μ„œ λ³Ό 수 μžˆλŠ” μ˜μ—­
  • λ””λ°”μ΄μŠ€(pc, tablets, phone...) 등에 따라 달라짐

❓ μ‚¬μš©ν•˜λŠ” 이유

  • μ›λž˜λŠ” μ›ΉνŽ˜μ΄μ§€λ₯Ό λ³΄μ—¬μ£ΌλŠ” λ””λ°”μ΄μŠ€λŠ” pcν•˜λ‚˜μ˜€μœΌλ‚˜
  • tablets, phone 등이 λ‚˜μ˜€λ©° λ””λ°”μ΄μŠ€μ— 따라 화면을 달리 보여쀄 ν•„μš”κ°€ 생김

πŸ”§ μ„€μ •

<meta name="viewport" content="width=device-width, initial-scale=1.0">

meta tag λ₯Ό 톡해 λΈŒλΌμš°μ €μ—₯ page 의 μΉ˜μˆ˜μ™€ λΉ„μœ¨μ„ μ–΄λ–»κ²Œ μ‘°μ ˆν•  건지 전달함

width=device-width

page λ₯Ό λ””λ°”μ΄μŠ€ ν™”λ©΄ 크기에 맞좀

initial-scale=1.0

초기 zoom 을 1.0 으둜 μ„€μ •

Media Query

πŸ€” μ •μ˜

  • νŠΉμ • 쑰건이 만쑱될 λ•Œλ§Œ css 속성이 μ μš©λ˜λ„λ‘ ν•˜λŠ” 기술

ex>

@media only screen and (max-width: 600px) {
  body {
    background-color: lightblue;
  }
}

=> ν™”λ©΄ λ„ˆλΉ„κ°€ 600px μ΄κ±°λ‚˜ μž‘μ„ λ•Œ body 색 λ³€κ²½

❓ μ‚¬μš©ν•˜λŠ”μ΄μœ 

  • λ””λ°”μ΄μŠ€μ— 따라 λ‹€λ₯Έ 화면을 μ‚¬μš©μžμ—κ²Œ 보여주기 μœ„ν•΄

πŸ“± μžμ£Όμ‚¬μš©λ˜λŠ” Breakpoints

/* Extra small devices (phones, 600px and down) */
@media only screen and (max-width: 600px) {...}

/* Small devices (portrait tablets and large phones, 600px and up) */
@media only screen and (min-width: 600px) {...}

/* Medium devices (landscape tablets, 768px and up) */
@media only screen and (min-width: 768px) {...}

/* Large devices (laptops/desktops, 992px and up) */
@media only screen and (min-width: 992px) {...}

/* Extra large devices (large laptops and desktops, 1200px and up) */
@media only screen and (min-width: 1200px) {...}

pc, λͺ¨λ°”일 λ‘κ°œλ‘œλ§Œ λΆ„λ₯˜ν•œλ‹€λ©΄ 768px λ₯Ό Breakpoints 둜 μ§€μ •ν•˜λ©΄ 될듯

πŸ–ΌοΈ Using The width Property

img {
  max-width: 100%;
  height: auto;
}

If the max-width property is set to 100%, the image will scale down if it has to, but never scale up to be larger than its original size:

max-width λ₯Ό 100% 둜 μ„€μ •ν•˜λ©΄ 화면이 μž‘μ•„μ Έ width 둜 μ„€μ •ν•œ 크기보닀 μž‘μ•„μ Έμ•Ό ν•˜λ©΄ 크기가 쀄어든닀.
μ°Έκ³ 

0개의 λŒ“κΈ€