๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Front-end/CSS

CSS overflow ์†์„ฑ

by ciocio 2021. 9. 26.

๐Ÿ“Œ  overflow 

 

์ฝ˜ํ…์ธ ๊ฐ€ ๋„ˆ๋ฌด ์ปค์„œ element์˜ Block Format Context๋ฅผ ๋งž์ถœ ์ˆ˜ ์—†์„ ๋•Œ์˜ ์ฒ˜๋ฆฌ๋ฒ•์„ ์ง€์ •ํ•œ๋‹ค.

 

ํ•„์š”ํ•œ ์†์„ฑ (ํƒ 1)

๐Ÿ“  ๋ธ”๋ก ๋ ˆ๋ฒจ ์ปจํ…Œ์ด๋„ˆ์˜ ๋†’์ด (height / max-height)
๐Ÿ“  white-space: nowrap 
 (โ€ป white-space ์†์„ฑ์€ element๊ฐ€ ๊ณต๋ฐฑ ๋ฌธ์ž๋ฅผ ์ฒ˜๋ฆฌํ•˜๋Š” ๋ฐฉ์‹์„ ๋‚˜ํƒ€๋‚ธ๋‹ค.)

 

 

โ—พ  overflow : visible;

 

See the Pen by ciocio97 (@ciocio97) on CodePen.

 

๊ธฐ๋ณธ๊ฐ’ /  ์ฝ˜ํ…์ธ ๋ฅผ ์ž๋ฅด์ง€ ์•Š๋Š”๋‹ค.

 

 

โ—พ  overflow : hidden;

 

See the Pen by ciocio97 (@ciocio97) on CodePen.

 

ํ•ด๋‹น element์˜ ํฌ๊ธฐ(์ •ํ•ด์ง„ ํฌ๊ธฐ)์— ๋งž์ถฐ ์ปจํ…์ธ ๋ฅผ ๊ณผ๊ฐํžˆ ์ž˜๋ผ๋ฒ„๋ฆฐ๋‹ค.

 

 

 

๐Ÿ“  overflow: hidden && scrollLeft EventHandler

 

See the Pen by ciocio97 (@ciocio97) on CodePen.

 

scrollLeft ์†์„ฑ์„ ์‚ฌ์šฉํ•˜์—ฌ ์Šคํฌ๋กคํ•˜๊ธฐ

 

 

 

โ—พ  overflow : scroll;

 

See the Pen by ciocio97 (@ciocio97) on CodePen.

 

์ฝ˜ํ…์ธ ๊ฐ€ ์ •ํ•ด์ง„ ํฌ๊ธฐ๋ฅผ ๋ฒ—์–ด๋‚˜๋“  ๋ง๋“  ์Šคํฌ๋กค๋ฐ”๋ฅผ ๋…ธ์ถœ์‹œํ‚จ๋‹ค. default๊ฐ’์œผ๋กœ ์Šคํฌ๋กค๋ฐ”๊ฐ€ ๋ถ™๋Š”๋‹ค.

 

 

โ—พ  overflow : auto;

 

See the Pen by ciocio97 (@ciocio97) on CodePen.

 

์ฝ˜ํ…์ธ ๊ฐ€ ์ •ํ•ด์ง„ ํฌ๊ธฐ๋ฅผ ๋ฒ—์–ด๋‚ฌ์„ ๋•Œ ์Šคํฌ๋กค๋ฐ”๋ฅผ ๋…ธ์ถœ์‹œํ‚จ๋‹ค. UI์ ์œผ๋กœ ๊ฐ€์žฅ ์•„๋ฆ„๋‹ค์›€ ๐Ÿ˜ƒ

 

 

 

๐Ÿ“Œ  overflow ์†์„ฑ์„ ๊ณต๋ถ€ํ•˜๊ฒŒ ๋œ ์ด์œ 

 

ํ‹ฐ์Šคํ† ๋ฆฌ ๋ธ”๋กœ๊ทธ ์Šคํ‚จ์„ ๋งŒ๋“ค๋˜ ์ค‘ ์ฒ˜์Œ๋ณด๋Š” ํƒœ๊ทธ css๋ฅผ ๋ฐœ๊ฒฌํ•˜์˜€๋‹ค !

 

#acc-nav {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1000;
  width: 100%;
  height: 0;
}

#acc-nav a {
  display: block;
  position: inherit;
  
  top: 0;
  left: 0;
  
  overflow: hidden;
  white-space: nowrap;

  width: 1px;
  height: 1px;
  margin-left: -1px;
  margin-bottom: -1px;
}

 

aํƒœ๊ทธ ์ž์ฒด๋ฅผ display: block์œผ๋กœ ๋ธ”๋Ÿญ์ฒ˜๋ฆฌ๋ฅผ ํ•˜๊ณ , overflow: hidden, white-space: nowrap ์„ ์ค˜์„œ

์ •ํ•ด์ง„ ํฌ๊ธฐ (width: 1px, height: 1px) ๋ฅผ ๋ฒ—์–ด๋‚˜์ง€ ๋ชปํ•˜๊ฒŒ ๋งŒ๋“ค์—ˆ๋‹ค.

 

๊ฒฐ๊ตญ ๋ Œ๋”๋ง ์ƒ์—๋Š” ์•„๋ฌด๊ฒƒ๋„ ํ‘œ์‹œ๋˜์ง€ ์•Š์•˜๋Š”๋ฐ ์ด๊ฒŒ ์–ด๋–ค ๊ฑธ ์˜๋ฏธํ•˜๋Š” ์ง€ ์ข€ ๋” ํŒŒ ๋ด์•ผ์•Œ ๊ฒƒ ๊ฐ™๋‹ค. 

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€