ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [CSS] ์ƒ‰์ƒ/๋ฐฐ๊ฒฝ ๊ด€๋ จ ์Šคํƒ€์ผ๊ณผ ์˜ˆ์ œ
    ๐ŸŒ FrontEnd/HTML & CSS 2022. 5. 20. 22:20

     

    ์‹œ์ž‘ํ•˜๋ฉด์„œ

    ์ƒ‰์ƒ, ๋ฐฐ๊ฒฝ๊ณผ ๊ด€๋ จ๋œ ์Šคํƒ€์ผ์„ ์˜ˆ์ œ์™€ ํ•จ๊ป˜ ๊ณต๋ถ€ํ•ฉ๋‹ˆ๋‹ค.

     

     

    1. ์›น์—์„œ ์ƒ‰์ƒ ํ‘œํ˜„ํ•˜๊ธฐ

    (1) 16์ง„์ˆ˜ ํ‘œ๊ธฐ๋ฒ•

    • #ffffff ์ฒ˜๋Ÿผ #๊ณผ ํ•จ๊ป˜ 6์ž๋ฆฌ์˜ 16์ง„์ˆ˜๋กœ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค.
    • ์•ž์—์„œ๋ถ€ํ„ฐ ๋‘ ์ž๋ฆฌ์”ฉ ๋นจ๊ฐ•, ์ดˆ๋ก, ํŒŒ๋ž‘์˜ ์–‘์ž…๋‹ˆ๋‹ค.
    • ํ•˜๋‚˜๋„ ์„ž์ด์ง€ ์•Š์•˜์„ ๋•Œ๋Š” 00, ๊ฐ€๋“ ์„ž์˜€์„ ๋•Œ๋Š” ff๋กœ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค.
    • ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๊ฐ’์€ 000000(๊ฒ€์€์ƒ‰)์—์„œ๋ถ€ํ„ฐ ffffff(ํฐ์ƒ‰)๊นŒ์ง€์ž…๋‹ˆ๋‹ค.
    /* ์˜ˆ */
    
    p { 
    	color: #000000; /* ๊ธ€์ž์ƒ‰ ๊ฒ€์ • */
    } 
    .accent { 
    	color: #ff0000; /* accent ํด๋ž˜์Šค ์Šคํƒ€์ผ์˜ ์ƒ‰ ๋นจ๊ฐ• */
    }

     

    (2) rgb์™€ rgba ํ‘œ๊ธฐ๋ฒ•

    • color: rgb(255, 0, 0) ์ฒ˜๋Ÿผ ์„ธ ์ž๋ฆฌ์˜ ์ˆซ์ž๋กœ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค.
    • ์•ž ์ˆซ์ž๋ถ€ํ„ฐ ๋นจ๊ฐ•, ์ดˆ๋ก, ํŒŒ๋ž‘์˜ ์–‘์ž…๋‹ˆ๋‹ค.
    • ํ•˜๋‚˜๋„ ์„ž์ด์ง€ ์•Š์•˜์„ ๋•Œ๋Š” 0, ๊ฐ€๋“ ์„ž์˜€์„ ๋•Œ๋Š” 255๋กœ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค.
    • ํˆฌ๋ช…๋„๋ฅผ ์กฐ์ ˆํ•  ๋•Œ๋Š” color: rgb(255, 0, 0, .3) ์ฒ˜๋Ÿผ ๋งˆ์ง€๋ง‰์— ์•ŒํŒŒ ๊ฐ’์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.
    • ์•ŒํŒŒ ๊ฐ’์€ ๋ถˆํˆฌ๋ช…๋„๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ๊ฐ’์œผ๋กœ 0~1 ๊ฐ’ ์ค‘์—์„œ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. 
      • (1์€ ๋ถˆํˆฌ๋ช…, 0์€ ์™„์ „ ํˆฌ๋ช…)

     

    /* ์˜ˆ */
    
    #box1 {
    	background-color: rgb(255, 0, 0); /* box1 ์ด๋ผ๋Š” ์Šคํƒ€์ผ์˜ ๋ฐฐ๊ฒฝ์ƒ‰์€ ๋นจ๊ฐ• ๊ณ„์—ด */
    }
    /* ๊ธฐ๋ณธํ˜• */
    
    rgba(red ๊ฐ’, green ๊ฐ’, blue ๊ฐ’, alpha ๊ฐ’);
    hsla(hue ๊ฐ’, saturation ๊ฐ’, lightness ๊ฐ’, alpha ๊ฐ’);

     

    • ํˆฌ๋ช…๋„๋ฅผ ์กฐ์ ˆํ•  ๋•Œ๋Š” ๋งˆ์ง€๋ง‰์— ์•ŒํŒŒ๊ฐ’์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.
    • ์•ŒํŒŒ๊ฐ’์€ ๋ถˆํˆฌ๋ช…๋„๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ๊ฐ’์œผ๋กœ 0~1 ๊ฐ’ ์ค‘์—์„œ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. (1์€ ๋ถˆํˆฌ๋ช…, 0์€ ์™„์ „ ํˆฌ๋ช…)
    /* ์˜ˆ : ๋ฐ˜ํˆฌ๋ช…ํ•œ ๋นจ๊ฐ„์ƒ‰ */
    
    rgba(255,0,0,0.5) /* ๋˜๋Š” */
    
    rgba(255,0,0,.5) /* ๋˜๋Š” */
    
    hsla(360,100%,50%,0.5)

     

     

    (3) hsl๊ณผ hsla ํ‘œ๊ธฐ๋ฒ•

    • color: hsl(240, 100%, 50%) ์ฒ˜๋Ÿผ ์„ธ ์ž๋ฆฌ์˜ ์ˆซ์ž๋กœ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค.
    • ์•ž์˜ ์ˆซ์ž๋ถ€ํ„ฐ ์ƒ‰์ƒ(hue), ์ฑ„๋„(saturation), ๋ฐ๊ธฐ(light)์˜ ์–‘ ์ž…๋‹ˆ๋‹ค.
    /* ์˜ˆ */
    
    #area2 {
    	background: hsl(360, 100%, 75%); /* ์ƒ‰์ƒ์€ ๋นจ๊ฐ•, ์ฑ„๋„ 100%, ๋ฐ๊ธฐ 75%์ธ ์ƒ‰ */
    }

     

    (4) ์ƒ‰์ƒ ์ด๋ฆ„ ํ‘œ๊ธฐ๋ฒ•

    • red๋‚˜ yellow, black ์ฒ˜๋Ÿผ ์ž˜ ์•Œ๋ ค์ง„ ์ƒ‰์ƒ ์ด๋ฆ„์œผ๋กœ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค.

     

    (1) ~ (4) ์˜ˆ์ œ

    <!DOCTYPE html>
    <html lang="ko">
    <head>
    	<meta charset="utf-8">
    	<title>Color in Web</title>
    	<style>
    		body {
    			background: hsl(240, 1000%, 75%);
    		}
    		.text1 {
    			color: #ffffff;
    		}
    		.text2 {
    			color: rgb(255,255,255);
    		}
    		.text3 {
    			color: rgba(255,255,255,0.2);
    		}
    		.text4 {
    			color: white;
    		}
    	</style>
    </head>
    <body>
    	<h1 class="text1">์ƒ‰์ƒ</h1>
    	<h1 class="text2">์ƒ‰์ƒ</h1>
    	<h1 class="text3">์ƒ‰์ƒ</h1>
    	<h1 class="text4">์ƒ‰์ƒ</h1>
    </body>
    </html>

     

    + ์ƒ‰์ƒ ์ถ”์ถœ ์‚ฌ์ดํŠธ ์ด์šฉํ•˜๊ธฐ

    • Color Picker ์‚ฌ์ดํŠธ๋ฅผ ์ด์šฉํ•ด์„œ ์›ํ•˜๋Š” ์ƒ‰์ƒ์„ ์ถ”์ถœํ•ฉ๋‹ˆ๋‹ค.
    • ๊ตฌ๊ธ€์— Color Picker ์„ ๊ฒ€์ƒ‰ํ•ด๋„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

     

     

    2. ๋ฐฐ๊ฒฝ์ƒ‰๊ณผ ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€

    (1) background-color ์†์„ฑ - ๋ฐฐ๊ฒฝ์ƒ‰ ์ง€์ •ํ•˜๊ธฐ

    • 16์ง„์ˆ˜๋‚˜ rgb ๊ฐ’, rgba ๊ฐ’ ๋˜๋Š” ์ƒ‰์ƒ ์ด๋ฆ„์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
    • background-color ๊ฐ’์€ ์ƒ์†๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
    /* ๊ธฐ๋ณธํ˜• */
    
    background-color: <์ƒ‰์ƒ>

     

    (1) ์˜ˆ์ œ

    <!DOCTYPE html>
    <html lang="ko">
    <head>
    	<meta charset="utf-8">
    	<title>์ดˆ์ฝ” ๋ฐฐ๊ฒฝ์ƒ‰</title>
    	<style>
    		body {
    			background-color:rgb(78, 16, 0); /* ๋ฌธ์„œ ์ „์ฒด ๋ฐฐ๊ฒฝ์ƒ‰ */
    		}
    		div {
    			background-color:white; /* div ์˜์—ญ ๋ฐฐ๊ฒฝ์ƒ‰ */
    			width:90%;  /* ๋„ˆ๋น„ */
    			padding:15px;  /* ํŒจ๋”ฉ */
    			border:1px solid black;  /* ํ…Œ๋‘๋ฆฌ */
    		}
    		p {
    			line-height:30px;
    		}
    	</style>
    </head>
    <body>
    	<div>
    		<h1>์ดˆ์ฝœ๋ฆฟ(Chocolate)</h1>
    		<p>
    			์ดˆ์ฝœ๋ฆฟ์€ ์นด์นด์˜ค ์ฝฉ์„ ์žฌ๋ฃŒ๋กœ ๊ฐ€๊ณตํ•œ ์‹ํ’ˆ์ด๋‹ค. 
    			์ˆ™์„ฑํ•œ ์นด์นด์˜ค ์ฝฉ์„ ๋ณถ์€ ๋’ค ์ด๋ฅผ ๊ฐˆ์•„์„œ ๋งŒ๋“  ์นด์นด์˜ค ๋งค์Šค์™€ ์ง€๋ฐฉ ์„ฑ๋ถ„๋งŒ์œผ๋กœ ๋งŒ๋“ค์–ด์ง„ ์ฝ”์ฝ”์•„ ๋ฒ„ํ„ฐ๋ฅผ ํ˜ผํ•ฉํ•˜์—ฌ ๋งŒ๋“œ๋Š”๋ฐ, 
    			์„คํƒ• ๋“ฑ์˜ ๋‹ค๋ฅธ ์žฌ๋ฃŒ๋ฅผ ๋” ๋„ฃ์–ด ๋งŒ๋“ค๊ธฐ๋„ ํ•œ๋‹ค. 
    			์นด์นด์˜ค ๋งค์Šค์˜ ํ•จ๋Ÿ‰์— ๋”ฐ๋ผ ๋‹คํฌ ์ดˆ์ฝœ๋ฆฟ, ๋ฐ€ํฌ ์ดˆ์ฝœ๋ฆฟ, ํ™”์ดํŠธ ์ดˆ์ฝœ๋ฆฟ์œผ๋กœ ๊ตฌ๋ถ„ํ•œ๋‹ค.
    		</p>
    	</div>
    </body>
    </html>

     

    (2) background-clip ์†์„ฑ ๋ฐฐ๊ฒฝ ์ ์šฉ ๋ฒ”์œ„ ์กฐ์ ˆํ•˜๊ธฐ

    • ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€๋‚˜ ๋ฐฐ๊ฒฝ์ƒ‰์„ ์–ด๋””๊นŒ์ง€ ์ ์šฉํ• ์ง€ ๋ฒ”์œ„๋ฅผ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.
      • border-box : ํ…Œ๋‘๋ฆฌ ๋ถ€๋ถ„๊นŒ์ง€ ์ ์šฉํ•ฉ๋‹ˆ๋‹ค.
      • padding-box : ํŒจ๋”ฉ ๋ถ€๋ถ„๊นŒ์ง€ ์ ์šฉํ•ฉ๋‹ˆ๋‹ค.
      • content-box : ๋งˆ์ง„ ๋ถ€๋ถ„๊นŒ์ง€ ์ ์šฉํ•ฉ๋‹ˆ๋‹ค.
    /* ๊ธฐ๋ณธํ˜• */
    
    background-clip : border-box | padding-box | content-box

     

    (2) ์˜ˆ์ œ

    <!DOCTYPE html>
    <html lang="ko">
    <head>
    	<meta charset="utf-8">
    	<title>๋ฐฐ๊ฒฝ ์ ์šฉ</title>
    	<style>
    		div {
    			width: 300px;
    			padding: 20px;
    			border: 5px dotted #00ff;
    			background: skyblue;
    			margin-bottom: 20px;
    		}
    	.bg1 { 
    			background-clip: border-box;
    	}
    	.bg2 { 
    			background-clip: padding-box;
    	}
    	.bg3 { 
    			background-clip: content-box;
    	}
    	</style>
    </head>
    <body>
    	<div class="bg1">
    		<p><strong>๋ฐฐ๊ฒฝ : </strong>
    			๋’ค ์ชฝ์˜ ๊ฒฝ์น˜. 
    			์ข์€ ์˜๋ฏธ๋กœ๋Š” ํŠน์ •ํ•œ ๋ฌผ์ฒด, ์ธ๋ฌผ, ์‚ฌ๊ฑด, ํ™˜๊ฒฝ ๋”ฐ์œ„๋ฅผ ๋‘˜๋Ÿฌ์‹ผ ์ฃผ์œ„์˜ ์ •๊ฒฝ์„ ๋œปํ•œ๋‹ค. 
    			๋˜๋Š” ์•ž์— ๋‚˜์„œ์ง€ ์•Š๊ณ  ๋’ค์—์„œ ๋Œ๋ณด์•„ ์ฃผ๋Š” ํž˜์„ ๋œปํ•˜๊ธฐ๋„ ํ•œ๋‹ค. 
    			์ด๋•Œ๋Š” ๋’ท๋ฐฐ๊ฒฝ์ด๋ผ๊ณ ๋„ ํ•œ๋‹ค.
    		</p>   
    	</div>
    	<div class="bg2">
    		<p> <strong>๋ฐฐ๊ฒฝ : </strong>
    		๋’ค ์ชฝ์˜ ๊ฒฝ์น˜. 
    		์ข์€ ์˜๋ฏธ๋กœ๋Š” ํŠน์ •ํ•œ ๋ฌผ์ฒด, ์ธ๋ฌผ, ์‚ฌ๊ฑด, ํ™˜๊ฒฝ ๋”ฐ์œ„๋ฅผ ๋‘˜๋Ÿฌ์‹ผ ์ฃผ์œ„์˜ ์ •๊ฒฝ์„ ๋œปํ•œ๋‹ค. 
    		๋˜๋Š” ์•ž์— ๋‚˜์„œ์ง€ ์•Š๊ณ  ๋’ค์—์„œ ๋Œ๋ณด์•„ ์ฃผ๋Š” ํž˜์„ ๋œปํ•˜๊ธฐ๋„ ํ•œ๋‹ค. 
    		์ด๋•Œ๋Š” ๋’ท๋ฐฐ๊ฒฝ์ด๋ผ๊ณ ๋„ ํ•œ๋‹ค.
    		</p> 
    	</div>
    	<div class="bg3">
    		<p> <strong>๋ฐฐ๊ฒฝ : </strong>
    		๋’ค ์ชฝ์˜ ๊ฒฝ์น˜. 
    		์ข์€ ์˜๋ฏธ๋กœ๋Š” ํŠน์ •ํ•œ ๋ฌผ์ฒด, ์ธ๋ฌผ, ์‚ฌ๊ฑด, ํ™˜๊ฒฝ ๋”ฐ์œ„๋ฅผ ๋‘˜๋Ÿฌ์‹ผ ์ฃผ์œ„์˜ ์ •๊ฒฝ์„ ๋œปํ•œ๋‹ค. 
    		๋˜๋Š” ์•ž์— ๋‚˜์„œ์ง€ ์•Š๊ณ  ๋’ค์—์„œ ๋Œ๋ณด์•„ ์ฃผ๋Š” ํž˜์„ ๋œปํ•˜๊ธฐ๋„ ํ•œ๋‹ค. 
    		์ด๋•Œ๋Š” ๋’ท๋ฐฐ๊ฒฝ์ด๋ผ๊ณ ๋„ ํ•œ๋‹ค.
    		</p> 
    	</div>
    </body>
    </html>

     

    (3) background-image ์†์„ฑ ์›น ์š”์†Œ์— ์ด๋ฏธ์ง€ ๋„ฃ๊ธฐ

    • ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€๋ฅผ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.
    • ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€ ํŒŒ์ผ ๊ฒฝ๋กœ๋Š” ์ƒ๋Œ€ ๊ฒฝ๋กœ ๋˜๋Š” ์ ˆ๋Œ€ ๊ฒฝ๋กœ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
    /* ์˜ˆ */
    
    body { 
    	background-image: url("bg1.png"); 
    } 
    #area { 
    	background-image: url("bg2.png"); 
    }

     

    (4) background-repeat ์†์„ฑ ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€ ๋ฐ˜๋ณตํ•˜๊ธฐ

    • ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€ ๋ฐ˜๋ณต ์—ฌ๋ถ€์™€ ๋ฐ˜๋ณต ๋ฐฉํ–ฅ์„ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.

     

    (5) background-size ์†์„ฑ - ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€ ํฌ๊ธฐ ์กฐ์ ˆํ•˜๊ธฐ

    • ์š”์†Œ ํฌ๊ธฐ์— ๋”ฐ๋ผ ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€๋ฅผ ์—ฌ๋Ÿฌ๊ฐ€์ง€ ํฌ๊ธฐ๋กœ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
    /* ๊ธฐ๋ณธํ˜• */
    
    background-size: auto | contain | cover | <ํฌ๊ธฐ ๊ฐ’> | <๋ฐฑ๋ถ„์œจ>

     

    (3) ~ (5) ์˜ˆ์ œ

    <!DOCTYPE html>
    <html lang="ko">
    <head>
    	<meta charset="utf-8">
    	<title>๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€</title>
    	<style>
    		div{
    			width:100px;
    			height:100px;
    			border:2px double gray;
    			margin-bottom:20px;
    			float: left;
    		}
    		.bg1{
    			background: url('images/bg4.jpg') no-repeat left top;
    			background-size:auto;
    		}
    		.bg2 {
    			background: url('images/bg4.jpg') no-repeat left top;
    			background-size:200px 150px;
    		}
    		.bg3 {
    			background: url('images/bg4.jpg') no-repeat left top;
    			background-size:60% 40%;
    		}
    		.bg4 {
    			background: url('images/bg4.jpg') no-repeat left top;
    			background-size:contain;
    		}
    		.bg5 {
    			background: url('images/bg4.jpg') no-repeat left top;
    			background-size:cover;
    		}
    		.bg6{
    			background: url('images/bg4.jpg') no-repeat left top;
    			background-size:100% 100%;
    		}
    	</style>
    </head>
    <body>
    	<div class="bg1"></div>
    	<div class="bg2"></div>
    	<div class="bg3"></div>
    	<div class="bg4"></div>
    	<div class="bg5"></div>
    	<div class="bg6"></div>
    </body>
    </html>

     

    (6) background-position ์†์„ฑ ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€ ์œ„์น˜ ์กฐ์ ˆํ•˜๊ธฐ

    • ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€๋ฅผ ๋ฐ˜๋ณตํ•˜์ง€ ์•Š๊ณ  ํ•œ๋ฒˆ๋งŒ ํ‘œ์‹œํ•  ๊ฒฝ์šฐ์— ํŠน์ •ํ•œ ์œ„์น˜์— ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€๋ฅผ ๋ฐฐ์น˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
    • ๋ฐฑ๋ถ„์œจ(%) ํ‘œ๊ธฐ๋ฒ• : ์ด๋ฏธ์ง€์˜ ๊ฐ€๋กœ ์œ„์น˜์™€ ์„ธ๋กœ ์œ„์น˜๋ฅผ %๋กœ ๋‚˜ํƒ€๋ƒ…๋‹ˆ๋‹ค.
    /* ์˜ˆ */
    
    background-postion: 0% 0%
    
    background-position: 20% 60%

     

    • ๊ธธ์ด(px) ํ‘œ๊ธฐ๋ฒ• : ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€์˜ ์œ„์น˜๋ฅผ ์ง์ ‘ ๊ธธ์ด๋กœ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.
    /* ์˜ˆ */
    
    background-position: 30px 20px;

     

    • ํ‚ค์›Œ๋“œ ํ‘œ๊ธฐ๋ฒ• :
      • ๊ฐ€๋กœ ๋ฐฐ์น˜๋Š” left์™€ center, right ์ค‘์—์„œ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.
      •  ์„ธ๋กœ ๋ฐฐ์น˜๋Š” top๊ณผ center, bottom ์ค‘์—์„œ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.

     

    /* ์˜ˆ */ 
    
    background-position: center bottom

     

    (6) ์˜ˆ์ œ

    <!DOCTYPE html>
    <html lang="ko">
    <head>
    	<meta charset="utf-8">
    	<title>๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€ ์œ„์น˜</title>
    	<style>
    		div {
    			position: relative;
    			left: 20%;
    			width: 80%;
    			height: auto;
    			border: 1px gray solid;
    			padding: 10px;
    			margin-bottom: 20px;
    		}
    		#bg1 {
    			background-image: url('images/bg2.jpg');
    			background-repeat: no-repeat;
    			background-position: left top;
    			padding-top: 150px;
    		}
    		#bg2 {
    			background-image: url('images/bg2.jpg');
    			background-repeat: no-repeat;
    			background-position: center;
    		}
    	</style>
    </head>
    <body>
    	<div id="bg1">
    		<h1>์ดˆ์ฝœ๋ฆฟ(Chocolate) ์Œ์‹๋“ค</h1>
    		<ul>
    			<li>์ดˆ์ฝœ๋ฆฟ ์•„์ด์Šคํฌ๋ฆผ</li>
    			<li>์ดˆ์ฝœ๋ฆฟ ์ผ€์ดํฌ</li>
    			<li>์ดˆ์ฝœ๋ฆฟ ์‰์ดํฌ</li>
    		</ul>
    	</div>
    	<div id="bg2">
    		<h1>์ดˆ์ฝœ๋ฆฟ(Chocolate) ์Œ์‹๋“ค</h1>
    		<ul>
    			<li>์ดˆ์ฝœ๋ฆฟ ์•„์ด์Šคํฌ๋ฆผ</li>
    			<li>์ดˆ์ฝœ๋ฆฟ ์ผ€์ดํฌ</li>
    			<li>์ดˆ์ฝœ๋ฆฟ ์‰์ดํฌ</li>
    		</ul>
    	</div>
    </body>
    </html>

     

    (7) background-origin ์†์„ฑ ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€ ์œ„์น˜ ๊ธฐ์ค€ ์กฐ์ ˆํ•˜๊ธฐ

    • ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€ ์œ„์น˜์˜ ๊ธฐ์ค€์„ ์–ด๋””๋กœ ํ• ์ง€ ์ง€์ •ํ•  ์ˆ˜ ์žˆ๋‹ค.
      • border-box : ๋ฐ•์Šค ๋ชจ๋ธ์˜ ๊ฐ€์žฅ ์™ธ๊ณฝ์ธ ํ…Œ๋‘๋ฆฌ(border)๊นŒ์ง€ ํฌํ•จํ•ด์„œ ๊ธฐ์ค€์ž…๋‹ˆ๋‹ค.
      • padding-box : ํ…Œ๋‘๋ฆฌ๋ฅผ ๋นผ๊ณ  ํŒจ๋”ฉ (padding) ๋ฒ”์œ„ ์•ˆ์—์„œ ๊ธฐ์ค€์ž…๋‹ˆ๋‹ค.
      • content-box : ๋‚ด์šฉ ๋ถ€๋ถ„๋งŒ ๊ธฐ์ค€์ž…๋‹ˆ๋‹ค.

     

    /* ๊ธฐ๋ณธํ˜• */
    
    background-origin: border-box | padding-box | content-box

     

    (7) ์˜ˆ์ œ

    <!DOCTYPE html>
    <html lang="ko">
    <head>
    	<meta charset="utf-8">
    	<title>๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€</title>
    	<style>
    		div {
    		width: 300px;
    		padding: 10px;
    		border: 10px  solid  #eee;
    		background: url('images/bg5.png') no-repeat;
    		margin-bottom: 20px;
    		}
    		.bg1 { 
    		background-origin: border-box;
    		}
    		.bg2 { 
    		background-origin: padding-box;
    		}
    		.bg3 { 
    		background-origin: content-box;
    		}
    	</style>
    </head>
    <body>
    	<div class="bg1">
    		<p> 
    			<strong>“๋ชจํžˆ๋˜ ๊ฐ€์„œ ๋ชฐ๋””๋ธŒ๋‚˜ ํ•œ์ž” ํ• ๊นŒ?”</strong>
    			๋ชจํžˆ๋˜๋Š” ์นตํ…Œ์ผ์˜ ์ผ์ข…์ด๊ณ , ๋ชฐ๋””๋ธŒ๋Š” ์ธ๋„์–‘์˜ ์„ฌ๋‚˜๋ผ์ด๋‹ค. 
    			๋”ฐ๋ผ์„œ “๋ชฐ๋””๋ธŒ์— ๊ฐ€์„œ ๋ชจํžˆ๋˜๋‚˜ ํ•œ์ž” ํ• ๊นŒ?”๊ฐ€ ๋ฐ”๋ฅธ ํ‘œํ˜„์ด๋‹ค. 
    			๊ทธ๋Ÿฐ๋ฐ ๋ชจํžˆ๋˜์— ๊ฐ€์„œ ๋ชฐ๋””๋ธŒ๋ฅผ ๋งˆ์‹ ๋‹ค๊ณ  ํ–ˆ๋‹ค.
    		</p>   
    	</div>
    	<div class="bg2">
    		<p>
    			<strong>“๋ชจํžˆ๋˜ ๊ฐ€์„œ ๋ชฐ๋””๋ธŒ๋‚˜ ํ•œ์ž” ํ• ๊นŒ?”</strong>
    			๋ชจํžˆ๋˜๋Š” ์นตํ…Œ์ผ์˜ ์ผ์ข…์ด๊ณ , ๋ชฐ๋””๋ธŒ๋Š” ์ธ๋„์–‘์˜ ์„ฌ๋‚˜๋ผ์ด๋‹ค. 
    			๋”ฐ๋ผ์„œ “๋ชฐ๋””๋ธŒ์— ๊ฐ€์„œ ๋ชจํžˆ๋˜๋‚˜ ํ•œ์ž” ํ• ๊นŒ?”๊ฐ€ ๋ฐ”๋ฅธ ํ‘œํ˜„์ด๋‹ค. 
    			๊ทธ๋Ÿฐ๋ฐ ๋ชจํžˆ๋˜์— ๊ฐ€์„œ ๋ชฐ๋””๋ธŒ๋ฅผ ๋งˆ์‹ ๋‹ค๊ณ  ํ–ˆ๋‹ค.
    		</p>
    	</div>
    	<div class="bg3">
    		<p>
    			<strong>“๋ชจํžˆ๋˜ ๊ฐ€์„œ ๋ชฐ๋””๋ธŒ๋‚˜ ํ•œ์ž” ํ• ๊นŒ?”</strong>
    			๋ชจํžˆ๋˜๋Š” ์นตํ…Œ์ผ์˜ ์ผ์ข…์ด๊ณ , ๋ชฐ๋””๋ธŒ๋Š” ์ธ๋„์–‘์˜ ์„ฌ๋‚˜๋ผ์ด๋‹ค. 
    			๋”ฐ๋ผ์„œ “๋ชฐ๋””๋ธŒ์— ๊ฐ€์„œ ๋ชจํžˆ๋˜๋‚˜ ํ•œ์ž” ํ• ๊นŒ?”๊ฐ€ ๋ฐ”๋ฅธ ํ‘œํ˜„์ด๋‹ค. 
    			๊ทธ๋Ÿฐ๋ฐ ๋ชจํžˆ๋˜์— ๊ฐ€์„œ ๋ชฐ๋””๋ธŒ๋ฅผ ๋งˆ์‹ ๋‹ค๊ณ  ํ–ˆ๋‹ค.
    		</p>
    	</div>
    </body>
    </html>

     

    (8) background-attachment ์†์„ฑ ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€ ๊ณ ์ •ํ•˜๊ธฐ

    • ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€๋ฅผ ๊ณ ์ •ํ•ฉ๋‹ˆ๋‹ค -> ์Šคํฌ๋กค ๋ง‰๋Œ€๋ฅผ ์›€์ง์ด๋”๋ผ๋„ ๋‚ด์šฉ๋งŒ ์Šคํฌ๋กค๋˜๋ฏ€๋กœ ๋งˆ์น˜ ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€ ์œ„์— ๋‚ด์šฉ์ด ๋–  ์žˆ๋Š” ๊ฒƒ์ฒ˜๋Ÿผ ๋ณด์ž…๋‹ˆ๋‹ค.
    • scroll : ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€๋„ ๋‚ด์šฉ ๋”ฐ๋ผ์„œ ์Šคํฌ๋กค ๋ฉ๋‹ˆ๋‹ค. (๊ธฐ๋ณธ ๊ฐ’)
    • fixed : ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€๊ฐ€ ๊ณ ์ •๋˜์–ด ์Šคํฌ๋กค ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
    /* ๊ธฐ๋ณธํ˜• */ 
    
    background-attachment: scroll | fixed

     

    (8) ์˜ˆ์ œ (๋ฒ ๋†ˆ ์‚ฌ์ง„ ์ฃผ์˜)

    <!DOCTYPE html>
    <html lang="ko">
    <head>
    	<meta charset="utf-8">
    	<title>๋ฒ ๋†ˆ ์Šคํฌ๋กค</title>
    	<style>
    		body {
    			background-image:url('images/venom.jpeg');
    			background-repeat: no-repeat;
    			background-position: center;
    			background-attachment: fixed;
    		}
    		div {
    			background:rgba(255,255,255,0.6);
    			width:80%;
    			height:auto;
    			margin-left:10%;
    		}
    	</style>
    </head>
    <body>
    	<div>
    		<h2>๋ฒ ๋†ˆ(Venom)</h2>
    		<p>
    			1984๋…„์— ์ฒซ ๋“ฑ์žฅํ•œ ์ŠคํŒŒ์ด๋”๋งจ์˜ ์ฃผ์š” ์Šˆํผ๋นŒ๋Ÿฐ ์ค‘ ํ•˜๋‚˜.
    			๊ฒ€์€ ์ŠคํŒŒ์ด๋”๋งจ ์ŠˆํŠธ๋ฅผ ๋ฐ”ํƒ•์œผ๋กœ ํ•œ ํ˜•ํƒœ์˜ ๋ชจ์Šต์— ์‹ฌ๋น„์˜คํŠธ ํŠน์œ ์˜ ์•ผ๋งŒ์ ์ธ ํฌ์Šค๊ฐ€ ์–ด์šฐ๋Ÿฌ์ ธ ์ŠคํŒŒ์ด๋”๋งจ์˜ ๋นŒ๋Ÿฐ ์ค‘ ๊ฐ€์žฅ ์ธ๊ธฐ๊ฐ€ ๋งŽ์€ ๋นŒ๋Ÿฐ์œผ๋กœ ์œ ๋ช…ํ•˜๋‹ค.
    			๊ทผ๋ณธ์ ์œผ๋กœ ์ž…์žฅ์ด ๋‹ค๋ฅธ ๊ฒฝ์šฐ๋ฅผ ์ œ์™ธํ•œ๋‹ค๋ฉด ๋‹ฅํ„ฐ ์˜ฅํ† ํผ์Šค์™€ ํ•จ๊ป˜ ์ˆœ์ˆ˜ ์–‘๋Œ€ ์ŠคํŒŒ์ด๋”๋งจ์˜ ์ˆ™์ ์ด๋ผ๊ณ  ํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ, ๋‹ฅํ„ฐ ์˜ฅํ† ํผ์Šค๋Š” ์ŠคํŒŒ์ด๋”๋งจ๊ณผ ๋™์งˆ์„ฑ์„ ์ง€๋‹ˆ๊ณ  ํˆฌ์Ÿํ•˜๋Š” ๊ฑฐ์šธ์˜ ์–‘๋ฉด๊ฐ™์€ ๊ด€๊ณ„๋ผ๋ฉด, ๋ฒ ๋†ˆ์€ ํ”ผํ„ฐ์—๊ฒŒ์„œ ๋‚˜์„œ ํ”ผํ„ฐ๋กœ ๋๋‚˜ ๋ณธ์งˆ์ ์œผ๋กœ ๋งˆ์ฃผํ•ด์•ผ ํ•˜๋Š” ๊ตด๋ ˆ์™€ ๊ฐ™๋‹ค๊ณ  ํ•  ์ˆ˜ ์žˆ๋‹ค.
    			๊ทธ ํƒ„์ƒ๋ถ€ํ„ฐ ์ŠคํŒŒ์ด๋”๋งจ์—์„œ ์‹œ์ž‘ํ•œ, ๊ทธ์•ผ๋ง๋กœ ์ŠคํŒŒ์ด๋”๋งจ์˜ ์•„์น˜ ์—๋„ˆ๋ฏธ.
    		</p>
    		<h2>์„ค๋ช…</h2>
    		<p>
    			์ŠคํŒŒ์ด๋”๋งจ์—๊ฒŒ์„œ ๋–จ์–ด์ ธ๋‚˜๊ฐ„ ์‹ฌ๋น„์˜คํŠธ๊ฐ€ ์ƒ์กด์„ ์œ„ํ•ด ๋‹ค๋ฅธ ์ˆ™์ฃผ๋ฅผ ์ฐพ์•„ ํƒ„์ƒํ•œ ๋นŒ๋Ÿฐ์œผ๋กœ, 1๋Œ€ ์—๋”” ๋ธŒ๋ก, 2๋Œ€ ์•ˆ์ ค๋กœ ํฌ์ธ„๋‚˜ํ† , 3๋Œ€ ๋งฅ ๊ฐ€๊ฐ„, 4๋Œ€ ํ”Œ๋ž˜์‹œ ํ†ฐ์Šจ, 5๋Œ€ ๋ฆฌ ํ”„๋ผ์ด์Šค, 6๋Œ€ ๋”œ๋Ÿฐ ๋ธŒ๋ก ์ด๋ ‡๊ฒŒ ์—ฌ์„ฏ ๋ช…์˜ ์ˆ™์ฃผ๊ฐ€ ๋‚˜์™”๊ณ , 
    			๋ฒˆ์™ธ๋กœ ์—๋””์˜ ์˜› ์•ฝํ˜ผ์ž '์•ค ์›จ์ž‰'์—๊ฒŒ ๋ถ™์€ ์‰ฌ ๋ฒ ๋†ˆ์ด ์žˆ๋‹ค. 
    			์•ž์—์„œ๋„ ์–ธ๊ธ‰ํ•˜๋‹ค์‹œํ”ผ ๋‹ฅํ„ฐ ์˜ฅํ† ํผ์Šค์™€ ๋”๋ถˆ์–ด ์ˆœ์ˆ˜ ์ŠคํŒŒ์ด๋”๋งจ ์ตœ์•…์˜ ์•„์น˜ ์—๋„ˆ๋ฏธ์ด๋‹ค.
    		</p>
    		<h2>ํ›„์†๋“ค</h2>
    		<ul>
    			<li>์นด๋‹ˆ์ง€ - ์ดˆ๋Œ€ ๋ฒ ๋†ˆ ์‹ฌ๋น„์˜คํŠธ์˜ ์ž์‹.</li>
    			<li>์Šคํฌ๋ฆผ - ๋ฒ ๋†ˆ ์‹ฌ๋น„์˜คํŠธ ๋ณต์ œํ’ˆ.</li>
    		</ul>   
    	</div>
    </body>
    </html>

    ์›€์ง์ด๋Š” ์ด๋ฏธ์ง€์ž…๋‹ˆ๋‹ค

     

    (9) background ์†์„ฑ ์†์„ฑ ํ•˜๋‚˜๋กœ ์‚ฌ์šฉํ•˜๊ธฐ

    • ๋ฐฐ๊ฒฝ๊ณผ ๊ด€๋ จ๋œ ์†์„ฑ์„ ํ•œ๊บผ๋ฒˆ์— ์ค„์—ฌ์„œ ํ‘œํ˜„ํ•ฉ๋‹ˆ๋‹ค.
    /* ์˜ˆ */
    
    body {
    	background: url(bg.jpg) center no-repeat fixed;
    }

     

     

    3. ๊ทธ๋ผ๋ฐ์ด์…˜ ํšจ๊ณผ๋กœ ๋ฐฐ๊ฒฝ ๊พธ๋ฏธ๊ธฐ

    (1) ๊ทธ๋Ÿฌ๋ฐ์ด์…˜ ๋ธŒ๋ผ์šฐ์ € ์ ‘๋‘์‚ฌ

    • ํ˜„์žฌ์˜ ํ‘œ์ค€ํ™”๋œ ๊ตฌ๋ฌธ ์™ธ์—๋„ ์ง€์›ํ•˜์ง€ ์•Š๋Š” ๋ธŒ๋ผ์šฐ์ €๋ฅผ ์œ„ํ•ด ์ ‘๋‘์‚ฌ๋ฅผ ๋ถ™์—ฌ ์ž…๋ ฅํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

     

    (1) ์˜ˆ์ œ

    <!DOCTYPE html>
    <html lang="ko">
    <head>
    	<meta charset="utf-8">
    	<title>๊ทธ๋ผ๋ฐ์ด์…˜</title>
    	<style>
    		div {
    			width: 700px;
    			height: 300px;
    			border-radius: 10px;
    		}
    		.grad {
    			background: blue; /* css3 ๋ฏธ์ง€์› ๋ธŒ๋ผ์šฐ์ € */
    			background: -webkit-linear-gradient(left top, blue, white); /* ์ดˆ๊ธฐ ๋ชจ๋˜ ๋ธŒ๋ผ์šฐ์ € */
    			background: -moz-linear-gradient(right bottom, blue, white); /* ์ดˆ๊ธฐ ๋ชจ๋˜ ๋ธŒ๋ผ์šฐ์ € */
    			background: -o-linear-gradient(right bottom, blue, white); /* ์ดˆ๊ธฐ ๋ชจ๋˜ ๋ธŒ๋ผ์šฐ์ € */
    			background: linear-gradient(to right bottom, blue, white); /* ์ตœ์‹  ๋ชจ๋˜ ๋ธŒ๋ผ์šฐ์ € */
    		}
    	</style>
    </head>
    <body>
    	<div class="grad"></div>
    </body>
    </html>

     

    (2) ์„ ํ˜• ๊ทธ๋ผ๋ฐ์ด์…˜

    • ์ˆ˜์ง ๋ฐฉํ–ฅ์ด๋‚˜ ์ˆ˜ํ‰ ๋ฐฉํ–ฅ์œผ๋กœ, ํ˜น์€ ๋Œ€๊ฐ์„  ๋ฐฉํ–ฅ์œผ๋กœ ์ƒ‰์ƒ์ด ์ผ์ •ํ•˜๊ฒŒ ๋ณ€ํ•˜๋Š” ๊ทธ๋ผ๋ฐ์ด์…˜์„ "์„ ํ˜• ๊ทธ๋ผ๋ฐ์ด์…˜"์ด๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค.
    • ์„ ํ˜• ๊ทธ๋ผ๋ฐ์ด์…˜์„ ์ง€์ •ํ•  ๋•Œ๋Š” ๋ฐฉํ–ฅ๊ณผ ์ƒ‰์ƒ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.
    • ์œ„์น˜:
      • to ์™€ ํ•จ๊ป˜ ์‚ฌ์šฉํ•ด์„œ ๋๋‚˜๋Š” ์œ„์น˜๋ฅผ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.
      • to left : ์˜ค๋ฅธ์ชฝ์—์„œ ์™ผ์ชฝ์œผ๋กœ, to right : ์™ผ์ชฝ์—์„œ ์˜ค๋ฅธ์ชฝ์œผ๋กœ,
      • to bottom : ์œ„์—์„œ ์•„๋ž˜๋กœ, to top : ์•„๋ž˜์—์„œ ์œ„๋กœ

     

    • ๊ฐ๋„:
      • ๊ทธ๋ผ๋ฐ์ด์…˜์˜ ๊ฐ๋„๋Š” ์„ ํ˜• ๊ทธ๋ผ๋ฐ์ด์…˜์˜ ๋ฐฉํ–ฅ์„ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.
      • ๋งจ ์œ—๋ถ€๋ถ„์ด 0deg์ด๊ณ , ์‹œ๊ณ„ ๋ฐฉํ–ฅ์œผ๋กœ ํšŒ์ „ํ•˜๋ฉด์„œ 90deg, 180deg๊ฐ€ ๋ฉ๋‹ˆ๋‹ค.
      • 270deg๋Š” –90deg์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค.
    /* ๊ธฐ๋ณธํ˜• */
    
    linear-gradient (๊ฐ๋„ ๋˜๋Š” ์œ„์น˜, color-stop, [color-stop,...]);

     

    (2) ์˜ˆ์ œ

    <!DOCTYPE html>
    <html lang="ko">
    <head>
    	<meta charset="utf-8">
    	<title>์„ ํ˜• ๊ทธ๋ผ๋ฐ์ด์…˜</title>
    	<style>
    		div {
    			width: 200px;
    			height: 200px;
    			border-radius: 10px;
    			float: left;
    			margin-left: 10px;
    		}
    		.line1 {
    			background: linear-gradient(90deg, red, white); /* 90๋„, ๋นจ๊ฐ„์ƒ‰, ํฐ์ƒ‰ */
    		}
    		.line2 {
    			background: linear-gradient(-90deg, blue, white); /* 270๋„, ํŒŒ๋ž€์ƒ‰, ํฐ์ƒ‰ */
    		}
    		.line3 {
    			background: linear-gradient(to bottom, yellow, white); /* ์œ„์—์„œ ์•„๋ž˜๋กœ, ๋…ธ๋ž€์ƒ‰์—์„œ ํฐ์ƒ‰์œผ๋กœ */
    		}
    		.line4 {
    			background: linear-gradient(to top, black, white 50%, black); /* ์•„๋ž˜์—์„œ ์œ„๋กœ, ๊ฒ€์ •์ƒ‰, 50% ์œ„์น˜์—์„œ ํฐ์ƒ‰์œผ๋กœ ๋ฐ”๋€Œ๊ณ  ๋‹ค์‹œ ๊ฒ€์ •์ƒ‰์œผ๋กœ */
    		}
    	</style>
    </head>
    <body>
    	<div class="line1"></div>
    	<div class="line2"></div>
    	<div class="line3"></div>
    	<div class="line4"></div>
    </body>
    </html>

     

    (3) ์›ํ˜• ๊ทธ๋ผ๋ฐ์ด์…˜

    • ์› ๋˜๋Š” ํƒ€์›์˜ ์ค‘์‹ฌ์—์„œ๋ถ€ํ„ฐ ๋™์‹ฌ์›์„ ๊ทธ๋ฆฌ๋ฉฐ ๋ฐ”๊นฅ ๋ฐฉํ–ฅ์œผ๋กœ ์ƒ‰์ƒ์ด ๋ฐ”๋€Œ๋Š” ๊ทธ๋ผ๋ฐ์ด์…˜์„ "์›ํ˜• ๊ทธ๋ผ๋ฐ์ด์…˜"์ด๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค.
    • ์œ„์น˜:
      • ์‹œ์ž‘ ์›(๋˜๋Š” ํƒ€์›)์˜ ์ค‘์‹ฌ๊ณผ ๋๋‚˜๋Š” ์›(๋˜๋Š” ํƒ€์›)์˜ ํฌ๊ธฐ๋ฅผ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.
      • ํ‚ค์›Œ๋“œ(๊ฐ€๋กœ:left, center, right, ์„ธ๋กœ: top, center, bottom) ๋˜๋Š” ๋ฐฑ๋ถ„์œจ์„ ์ด์šฉํ•ฉ๋‹ˆ๋‹ค.
      • ์ƒ๋žตํ•˜๋ฉด center center๋กœ ์ธ์‹ํ•ฉ๋‹ˆ๋‹ค.

     

    • ๋ชจ์–‘:
      • ๊ทธ๋ผ๋ฐ์ด์…˜์˜ ๋ชจ์–‘์„ ์›(circle)๊ณผ ํƒ€์›(ellipse) ์ค‘์—์„œ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.

     

    • ํฌ๊ธฐ:
      • closest-side : ๊ทธ๋ผ๋ฐ์ด์…˜ ๊ฐ€์žฅ์ž๋ฆฌ๊ฐ€ ๊ทธ๋ผ๋ฐ์ด์…˜ ์ค‘์‹ฌ์—์„œ ๊ฐ€์žฅ ๊ฐ€๊นŒ์šด ์š”์†Œ์˜ ๋ชจ์„œ๋ฆฌ์™€ ๋งŒ๋‚ฉ๋‹ˆ๋‹ค.
      • closest-corner : ๊ทธ๋ผ๋ฐ์ด์…˜ ๊ฐ€์žฅ์ž๋ฆฌ๊ฐ€ ๊ทธ๋ผ๋ฐ์ด์…˜ ์ค‘์‹ฌ์—์„œ ๊ฐ€์žฅ ๊ฐ€๊นŒ์šด ์š”์†Œ์˜ ์ฝ”๋„ˆ์— ๋‹ฟ๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.
      • farthest-side : ๊ทธ๋ผ๋ฐ์ด์…˜ ๊ฐ€์žฅ์ž๋ฆฌ๊ฐ€ ๊ทธ๋ผ๋ฐ์ด์…˜ ์ค‘์‹ฌ์—์„œ ๊ฐ€์žฅ ๋ฉ€๋ฆฌ ๋–จ์–ด์ ธ ์žˆ๋Š” ๋ชจ์„œ๋ฆฌ์™€ ๋งŒ๋‚  ๋•Œ๊นŒ์ง€ ๊ทธ๋ฆฝ๋‹ˆ๋‹ค.
      • farthest-corner : ๊ทธ๋ผ๋ฐ์ด์…˜์˜ ๊ฐ€์žฅ์ž๋ฆฌ๊ฐ€ ๊ทธ๋ผ๋ฐ์ด์…˜์˜ ์ค‘์‹ฌ์—์„œ ๊ฐ€์žฅ ๋ฉ€๋ฆฌ ๋–จ์–ด์ ธ์žˆ๋Š” ์ฝ”๋„ˆ์— ๋‹ฟ๋„๋ก ํ•ฉ๋‹ˆ๋‹ค. (๊ธฐ๋ณธ ๊ฐ’)

     

    (3) ์˜ˆ์ œ

    <!DOCTYPE html>
    <html lang="ko">
    <head>
    	<meta charset="utf-8">
    	<title>์›ํ˜• ๊ทธ๋ผ๋ฐ์ด์…˜</title>
    	<style>
    		div {
    			width: 200px;
    			height: 200px;
    			float: left;
    			margin-left: 10px;
    			margin-bottom: 10px;
    		}
    		.rad1 {
    			background: -webkit-radial-gradient(10% 10%, ellipse, white, red); /* 10% 10%์—์„œ ์‹œ์ž‘ํ•˜์—ฌ ๋นจ๊ฐ„์ƒ‰์—์„œ ํฐ์ƒ‰์œผ๋กœ ๋ฒˆ์ง€๋Š” ํƒ€์›ํ˜• ๊ทธ๋ผ๋ฐ์ด์…˜ */
    		}
    		.rad2 {
    			background: radial-gradient(circle closest-side at 30% 40%, white, yellow, green);    
    		}
    		.rad3 {
    			background: radial-gradient(circle closest-corner at 30% 40%, white, yellow, green);
    		}
    		.rad4 {
    			background: radial-gradient(circle farthest-side at 30% 40%, white, yellow, green);
    		}
    		.rad5 {
    			background: radial-gradient(circle farthest-corner at 30% 40%, white, yellow, green);
    		}
    	</style>
    </head>
    <body>
    	<div class="rad1"></div>
    	<div class="rad2"></div>
    	<div class="rad3"></div>
    	<div class="rad4"></div>
    	<div class="rad5"></div>
    </body>
    </html>

    ์˜ˆ์ œ ์ง„ํ–‰ ์ค‘ ํฌ๋กฌ ๊ธฐ์ค€ radial-gradient(10% 10%, ellipse, white, red) ๋ถ€๋ถ„์ด ์ ์šฉ๋˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.
    webkit prefix (์ ‘๋‘์‚ฌ) ๋ฅผ ๋‹ฌ์•„์ฃผ๋ฉด ์ œ๋Œ€๋กœ ๊ธฐ๋Šฅํ•ฉ๋‹ˆ๋‹ค. ๋‹ค์–‘ํ•œ ๋ธŒ๋ผ์šฐ์ € ํ™˜๊ฒฝ์„ ์œ„ํ•ด ๊ผญ ์ ‘๋‘์‚ฌ๋ฅผ ๋‹ฌ์•„์ฃผ์–ด์•ผ ํ•  ํ•„์š”์„ฑ์„ ๋Š๊ผˆ์Šต๋‹ˆ๋‹ค.

     

    (4) ๊ทธ๋ผ๋ฐ์ด์…˜ ๋ฐ˜๋ณต

    • repeating-linear-gradient: ์„ ํ˜• ๊ทธ๋ผ๋ฐ์ด์…˜์„ ๋ฐ˜๋ณตํ•ฉ๋‹ˆ๋‹ค.
    • repeating-radial-gradient: ์›ํ˜• ๊ทธ๋ผ๋ฐ์ด์…˜์„ ๋ฐ˜๋ณตํ•ฉ๋‹ˆ๋‹ค.

     

    (4) ์˜ˆ์ œ

    <!DOCTYPE html>
    <html lang="ko">
    <head>
    	<meta charset="utf-8">
    	<title>์„ ํ˜• ์›ํ˜• ๊ทธ๋ผ๋ฐ์ด์…˜ ๋ฐ˜๋ณต</title>
    	<style>
    		div {
    			width:300px;
    			height:300px;
    			border-radius:10px;
    			margin:10px;
    		}
    		.grad1 {
    			background: red; /* css3 ๋ฏธ์ง€์› ๋ธŒ๋ผ์šฐ์ € */
    			background: -webkit-repeating-linear-gradient(yellow, yellow 20px, red 20px, red 40px); /* ์ดˆ๊ธฐ ๋ชจ๋˜ ๋ธŒ๋ผ์šฐ์ € */
    			background: -moz-repeating-linear-gradient(yellow, yellow 20px, red 20px, red 40px); /* ์ดˆ๊ธฐ ๋ชจ๋˜ ๋ธŒ๋ผ์šฐ์ € */
    			background: -o-repeating-linear-gradient(yellow, yellow 20px, red 20px, red 40px); /* ์ดˆ๊ธฐ ๋ชจ๋˜ ๋ธŒ๋ผ์šฐ์ € */
    			background: repeating-linear-gradient(yellow, yellow 20px, red 20px, red 40px); /* ์ตœ์‹  ๋ชจ๋˜ ๋ธŒ๋ผ์šฐ์ € */
    		}
    		.grad2 {
    			background: #ccc; /* css3 ๋ฏธ์ง€์› ๋ธŒ๋ผ์šฐ์ € */
    			background: -webkit-repeating-radial-gradient(circle, white, white 10%, #ccc 10%, #ccc 30%); /* ์ดˆ๊ธฐ ๋ชจ๋˜ ๋ธŒ๋ผ์šฐ์ € */
    			background: -moz-repeating-radial-gradient(circle, white, white 10%, #ccc 10%, #ccc 30%); /* ์ดˆ๊ธฐ ๋ชจ๋˜ ๋ธŒ๋ผ์šฐ์ € */
    			background: -o-repeating-radial-gradient(circle, white, white 10%, #ccc 10%, #ccc 30%); /* ์ดˆ๊ธฐ ๋ชจ๋˜ ๋ธŒ๋ผ์šฐ์ € */
    			background: repeating-radial-gradient(circle, white, white 10%, #ccc 10%, #ccc 30%); /* ์ตœ์‹  ๋ชจ๋˜ ๋ธŒ๋ผ์šฐ์ € */
    		}
    	</style>
    </head>
    <body>
    	<div class="grad1"></div>
    	<div class="grad2"></div>
    </body>
    </html>

     

    ๋งˆ๋ฌด๋ฆฌํ•˜๋ฉฐ

    ์ƒ‰์ƒ ๊ทธ๋ฆฌ๊ณ  ๋ฐฐ๊ฒฝ๊ณผ ๊ด€๋ จ๋œ ์Šคํƒ€์ผ์„ ์˜ˆ์ œ์™€ ํ•จ๊ป˜ ๊ณต๋ถ€ํ•ด ๋ณด์•˜์Šต๋‹ˆ๋‹ค.

    ๋‹ค์ŒํŽธ๋„ ์Šคํƒ€์ผ์„ ๊ณต๋ถ€ํ•ฉ๋‹ˆ๋‹ค.

     

    ๋Œ“๊ธ€๊ณผ ๊ณต๊ฐ์€ ํ•ญ์ƒ ํ™˜์˜์ž…๋‹ˆ๋‹ค!

    ๋Œ“๊ธ€