๐Ÿ“ŒLanguage/HTML & CSS

TIL) overflow-clip-margin ์†์„ฑ์œผ๋กœ ์ •๋ฐ€ํ•œ ํด๋ฆฌํ•‘ ์ œ์–ดํ•˜๊ธฐ

hellohailie 2024. 7. 10. 00:27
๋ฐ˜์‘ํ˜•

 

 

2์ค‘ border๋ฅผ ์‚ฌ์šฉํ•˜๋Š”๋ฐ ๊ฐ๋„๊ฐ€ ๋งž์ง€ ์•Š์•„์„œ ์ด๋ฆฌ์ €๋ฆฌ ์ฐพ์•„๋ณด๋‹ค๊ฐ€ ๋ฐœ๊ฒฌํ•˜๊ฒŒ ๋œ CSS ์ž…๋‹ˆ๋‹ค. 

 

overflow-clip-margin

 

overflow-clip-margin = overflow ์†์„ฑ ๊ฐ’์ด clip์ธ ๊ฒฝ์šฐ์—๋งŒ ๋™์ž‘ํ•˜๋ฉฐ, ๋ฐ”๊นฅ์ชฝ ๋ฒ”์œ„๋ฅผ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค. 

 

๐Ÿ‘€ ๋ˆˆ์œผ๋กœ ์•Œ์•„๋ณด๊ธฐ

 

๊ธฐ๋ณธ HTML

<div class="container">
	<div class="content">
		์ด ๋‚ด์šฉ์€ ์ปจํ…Œ์ด๋„ˆ๋ฅผ ๋„˜์–ด์„œ์ง€๋งŒ, ํด๋ฆฌํ•‘ ๋งˆ์ง„ ๋•๋ถ„์— ์—ฌ์œ  ๊ณต๊ฐ„์ด ์žˆ์Šต๋‹ˆ๋‹ค.
	</div>
</div>

 

.container {
	width: 300px;
	height: 200px;
	border: 2px solid #000;
}

.content {
	width: 350px;
	height: 250px;
	background-color: lightblue;
}

 

๋ฅผ ์ ์šฉํ•˜์ง€ ์•Š์•˜๋‹ค๋ฉด,

 

.content์˜ ๋„ˆ๋น„์ธ 350px๋กœ ๋„˜์–ด๊ฐ€๋ฒ„๋ฆฝ๋‹ˆ๋‹ค. 

 


 

overflow-clip-margin์„ ์„ค์ •ํ•œ๋‹ค๋ฉด, ๋”ฑ 30px์ด ๋„˜์–ด๊ฐ‘๋‹ˆ๋‹ค. 

overflow: clip;
overflow-clip-margin: 30px; /* ํด๋ฆฌํ•‘ ์˜์—ญ์„ 30px ํ™•์žฅ */

 


 

length๊ฐ€ ์•„๋‹Œ visusal-box ๊ฐ’์œผ๋กœ๋„ ์ œ์–ด๊ฐ€ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. 

<visual-box> = content-box  |  padding-box  |  border-box

 

 

TIP) ๋‘˜ ๋‹ค ์จ์•ผํ•œ๋‹ค๋ฉด,

overflow-clip-margin: 15px;
overflow-clip-margin-box: border-box;

 


 

overflow-clip-margin์„ content-box๋กœ ์„ค์ •ํ•œ๋‹ค๋ฉด, .container ์š”์†Œ๋Š” content-box๋ฅผ ๊ธฐ์ค€์œผ๋กœ ํด๋ฆฌํ•‘๋ฉ๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ content ์š”์†Œ์˜ ๋‚ด์šฉ์ด content ์˜์—ญ์„ ๋ฒ—์–ด๋‚˜๋ฉด ์ž˜๋ฆฌ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

 

overflow: clip;
overflow-clip-margin: content-box;

 

 

 


 

overflow-clip-margin์„ padding-box๋กœ ์„ค์ •ํ•œ๋‹ค๋ฉด, .container ์š”์†Œ๋Š” padding-box๋ฅผ ๊ธฐ์ค€์œผ๋กœ ํด๋ฆฌํ•‘๋ฉ๋‹ˆ๋‹ค. ํŒจ๋”ฉ์„ ํฌํ•จํ•œ ์˜์—ญ์„ ๋ฒ—์–ด๋‚œ content ์š”์†Œ์˜ ๋‚ด์šฉ์ด ์ž˜๋ฆฌ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

 

.container {
            width: 300px;
            height: 200px;
            border: 2px solid #000;
            padding: 10px;
            overflow: clip;
            overflow-clip-margin: padding-box;
}

overflow-clip-margin: padding-box;

 

overflow-clip-margin: content-box;

 

overflow-clip-margin: border-box;

 

์œ„ ์‚ฌ์ง„์ฒ˜๋Ÿผ overflow-clip-margin์„ border-box๋กœ ์„ค์ •ํ•œ๋‹ค๋ฉด, .container ์š”์†Œ๋Š” border-box๋ฅผ ๊ธฐ์ค€์œผ๋กœ ํด๋ฆฌํ•‘๋ฉ๋‹ˆ๋‹ค. ๋ณด๋”๋ฅผ ํฌํ•จํ•œ ์˜์—ญ์„ ๋ฒ—์–ด๋‚œ content ์š”์†Œ์˜ ๋‚ด์šฉ์ด ์ž˜๋ฆฌ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

 

  • border-box๋Š” ์š”์†Œ์˜ ๋ณด๋”(border) ์˜์—ญ์„ ๊ธฐ์ค€์œผ๋กœ ํด๋ฆฌํ•‘์ด ์ด๋ฃจ์–ด์ง‘๋‹ˆ๋‹ค. ํŒจ๋”ฉ๊ณผ ์ฝ˜ํ…์ธ  ์˜์—ญ์„ ๋ชจ๋‘ ํฌํ•จํ•ฉ๋‹ˆ๋‹ค.

 

 


ChatGPT์—๊ฒŒ ๋ฌผ์–ด๋ณด๋‹ˆ, ์•„๋ž˜ ์ƒํ™ฉ์—์„œ ์œ ์šฉํ•˜๊ฒŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค๊ณ  ํ•˜๋„ค์š”!

 

1. ์ •๋ฐ€ํ•œ ํด๋ฆฌํ•‘ ์ œ์–ด

  • ์š”์†Œ์˜ ๋‚ด์šฉ์ด ๊ฒฝ๊ณ„์— ๋งž๋‹ฟ์„ ๋•Œ: ํŠน์ • ์š”์†Œ์˜ ๋‚ด์šฉ์ด ๋ถ€๋ชจ ์š”์†Œ์˜ ๊ฒฝ๊ณ„์— ๋งค์šฐ ๊ทผ์ ‘ํ•˜๊ฑฐ๋‚˜ ๋งž๋‹ฟ์„ ๋•Œ, ์‹œ๊ฐ์ ์œผ๋กœ ๋” ๋ถ€๋“œ๋Ÿฌ์šด ํšจ๊ณผ๋ฅผ ์ฃผ๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ํด๋ฆฌํ•‘ ๋งˆ์ง„์„ ์ถ”๊ฐ€ํ•˜์—ฌ ๋‚ด์šฉ์ด ์™„์ „ํžˆ ์ž˜๋ฆฌ์ง€ ์•Š๋„๋ก ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

2. ์‹œ๊ฐ์  ์—ฌ๋ฐฑ ์ถ”๊ฐ€

  • ์—ฌ๋ฐฑ์„ ํ†ตํ•ด ์‹œ๊ฐ์  ๊ท ํ˜•์„ ๋งž์ถ”๊ณ  ์‹ถ์„ ๋•Œ: ํ…์ŠคํŠธ๋‚˜ ์ด๋ฏธ์ง€ ๊ฐ™์€ ์ฝ˜ํ…์ธ ๊ฐ€ ์š”์†Œ์˜ ๊ฒฝ๊ณ„์™€ ๋„ˆ๋ฌด ๊ฐ€๊นŒ์šธ ๋•Œ, ์•ฝ๊ฐ„์˜ ์—ฌ๋ฐฑ์„ ์ฃผ์–ด ์‹œ๊ฐ์ ์œผ๋กœ ๊ท ํ˜•์„ ๋งž์ถœ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ํŠนํžˆ ๋””์ž์ธ์ ์œผ๋กœ ์—ฌ์œ  ๊ณต๊ฐ„์ด ํ•„์š”ํ•  ๋•Œ ์œ ์šฉํ•ฉ๋‹ˆ๋‹ค.

3. ๋ณต์žกํ•œ ๋ ˆ์ด์•„์›ƒ์—์„œ์˜ ์‚ฌ์šฉ

  • UI ๊ตฌ์„ฑ ์š”์†Œ๊ฐ€ ๋ณต์žกํ•œ ๋ ˆ์ด์•„์›ƒ์— ์žˆ์„ ๋•Œ: ๋‹ค์–‘ํ•œ ๊ตฌ์„ฑ ์š”์†Œ๊ฐ€ ์–ฝํ˜€ ์žˆ๋Š” ๋ณต์žกํ•œ ๋ ˆ์ด์•„์›ƒ์—์„œ ๊ฐ ์š”์†Œ์˜ ํด๋ฆฌํ•‘์„ ์„ธ๋ฐ€ํ•˜๊ฒŒ ์กฐ์ •ํ•ด์•ผ ํ•  ๋•Œ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ์ด๋กœ ์ธํ•ด ๋ ˆ์ด์•„์›ƒ์ด ๋” ๊น”๋”ํ•˜๊ณ  ๋ณด๊ธฐ ์ข‹๊ฒŒ ์ •๋ˆ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

4. ์• ๋‹ˆ๋ฉ”์ด์…˜ ๋ฐ ์ธํ„ฐ๋ž™ํ‹ฐ๋ธŒ ์š”์†Œ

  • ์• ๋‹ˆ๋ฉ”์ด์…˜์ด๋‚˜ ๋™์  ์ฝ˜ํ…์ธ ๋ฅผ ๋‹ค๋ฃฐ ๋•Œ: ์• ๋‹ˆ๋ฉ”์ด์…˜์ด ์ ์šฉ๋œ ์š”์†Œ๋‚˜ ์‚ฌ์šฉ์ž์™€์˜ ์ƒํ˜ธ์ž‘์šฉ์ด ๋งŽ์€ ๋™์  ์ฝ˜ํ…์ธ ์˜ ๊ฒฝ์šฐ, ํด๋ฆฌํ•‘ ์˜์—ญ์„ ์ ์ ˆํžˆ ์„ค์ •ํ•˜์—ฌ ๋ถ€๋“œ๋Ÿฌ์šด ๋™์ž‘์„ ๋ณด์žฅํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

 

 

๐Ÿ˜ƒ ์ž˜๋ชป๋œ ๊ฐœ๋… ์ „๋‹ฌ์ด ์žˆ๋‹ค๋ฉด ๋Œ“๊ธ€ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค. ์ €์˜ ์„ฑ์žฅ์— ํฐ ๋„์›€์ด ๋ฉ๋‹ˆ๋‹ค๐Ÿค“

 

๋ฐ˜์‘ํ˜•