๋ณธ๋ฌธ์œผ๋กœ ๊ฑด๋„ˆ๋›ฐ๊ธฐ

CSS ์†์„ฑ 07. overflow

โ—๏ธ ํ•ด๋‹น ๊ธ€์€ ํŒจ์ŠคํŠธ์บ ํผ์Šค - ํ”„๋ก ํŠธ์—”๋“œ ๊ฐœ๋ฐœ ๊ฐ•์˜์—์„œ HTML & CSS, SASS(SCSS) Part์˜ ๋ฐ•์˜์›… ๊ฐ•์‚ฌ๋‹˜์˜ ๊ฐ•์˜์ž๋ฃŒ๋ฅผ ์ •๋ฆฌํ•œ ๊ฒƒ์ž…๋‹ˆ๋‹ค.

overflow#

์š”์†Œ์˜ ํฌ๊ธฐ ์ด์ƒ์œผ๋กœ ๋‚ด์šฉ(์ž์‹์š”์†Œ)์ด ๋„˜์ณค์„ ๋•Œ, ๋‚ด์šฉ์˜ ๋ณด์—ฌ์ง์„ ์ œ์–ด - ๋‹จ์ถ• ์†์„ฑ


์†์„ฑ ๊ฐ’#

๊ฐ’์˜๋ฏธ๊ธฐ๋ณธ๊ฐ’
visible๋„˜์นœ ๋ถ€๋ถ„์„ ์ž๋ฅด์ง€ ์•Š๊ณ  ๊ทธ๋Œ€๋กœ ๋ณด์—ฌ์คŒvisible
hidden๋„˜์นœ ๋ถ€๋ถ„์„ ์ž˜๋ผ๋‚ด๊ณ , ๋ณด์ด์ง€ ์•Š๋„๋ก ํ•จ
scroll๋„˜์นœ ๋ถ€๋ถ„์„ ์ž˜๋ผ๋‚ด๊ณ , ์Šคํฌ๋กค ๋ฐ”๋ฅผ ์ด์šฉํ•˜์—ฌ ๋ณผ ์ˆ˜ ์žˆ๋„๋ก ํ•จ
auto๋„˜์นœ ๋ถ€๋ถ„์ด ์žˆ๋Š” ๊ฒฝ์šฐ๋งŒ ์ž˜๋ผ๋‚ด ์Šคํฌ๋กค ๋ฐ”๋ฅผ ์ด์šฉํ•˜์—ฌ ๋ณผ ์ˆ˜ ์žˆ๋„๋ก ํ•จ

์‚ฌ์šฉ๋ฒ•#

overflow: visible;overflow: hidden;overflow: scroll;overflow: auto

์˜ˆ์ œ#

<div class="parent"><div class="child">1</div><div class="child">2</div><div class="child">3</div></div>
.parent {width: 300px;height: 250px;border: 4px solid;overflow: scroll;}.parent .child {width: 100px;height: 100px;background: tomato;border: 4px solid red;display: flex;justify-content: center;align-items: center;font-size: 40px;}

โ˜๏ธ scroll ์€ overflow๊ฐ€ ๋ฐœ์ƒํ•˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ์—๋„ ์Šคํฌ๋กค ๋ฐ”๋ฅผ ์ƒ์„ฑํ•œ๋‹ค. ๋ฐ˜๋ฉด auto ๋Š” overflow๊ฐ€ ๋ฐœ์ƒํ•˜๋Š” ๊ฒฝ์šฐ์—๋งŒ ์Šคํฌ๋กค ๋ฐ”๋ฅผ ์ƒ์„ฑํ•œ๋‹ค.


overflow-x , overflow-y#

x์ถ•๊ณผ y์ถ•์— ๋Œ€ํ•ด ๊ฐ๊ฐ overflow๋ฅผ ์„ค์ •ํ•  ์ˆ˜ ์žˆ๋‹ค.

๊ทธ๋Ÿฐ๋ฐ scroll ๊ณผ, auto ์˜ ๊ฒฝ์šฐ์— ๋‘˜ ์ค‘ ํ•˜๋‚˜๋งŒ ์„ค์ •ํ•˜๋ฉด ๋ชจ๋“  ๋ฐฉํ–ฅ์— ๋Œ€ํ•ด ์Šคํฌ๋กค ๋ฐ”๊ฐ€ ์ ์šฉ๋œ๋‹ค.

overflow-x: scroll;
overflow-y: scroll;
overflow-x: auto;
overflow-y: auto;

Reference#

ํŒจ์ŠคํŠธ์บ ํผ์Šค - ํ”„๋ก ํŠธ์—”๋“œ ๊ฐœ๋ฐœ ๊ฐ•์˜ - HTML & CSS, SASS(SCSS) Part by ParkYoungWoong