IV. ๋ฐฐ๊ฒฝ๊พธ๋ฏธ๊ธฐ - 3. ๊ทธ๋ผ๋ฐ์ด์ ํจ๊ณผ๋ก ๋ฐฐ๊ฒฝ ๊พธ๋ฏธ๊ธฐ
์ ํ ๊ทธ๋ผ๋ฐ์ด์
์์์ด ์์ง, ์ํ ๋๋ ๋๊ฐ์ ๋ฐฉํฅ์ผ๋ก ์ผ์ ํ๊ฒ ๋ณํ๋ ๊ฒ์ ๋งํ๋ค.
์ด๊ฒ์ ๋ง๋ค์ด ์ฃผ๋ ํจ์๋ linear-gradient์ธ๋ฐ ์์์ด ์ด๋ ๋ฐฉํฅ์ผ๋ก ๋ฐ๋๋์ง, ์ด๋ค ์์์ผ๋ก ๋ฐ๋๋์ง ์๋ ค ์ฃผ์ด์ผ ํ๋ค.
์ ํ ๊ทธ๋ผ๋ฐ์ด์ ์ ๊ธฐ๋ณธํ์ ๋ค์๊ณผ ๊ฐ๋ค.
linear-gradient(to <๋ฐฉํฅ> ๋๋ <๊ฐ๋>, <์์ ์ค์ง์ >, [<์์ ์ค์ง์ >, ... ]);
-๋ฐฉํฅ
๊ทธ๋ผ๋ฐ์ด์ ๋ฐฉํฅ์ ์ง์ํ ๋๋ ๋ ์ง์ ์ ๊ธฐ์ค์ผ๋ก to ์์ฝ์ด์ ํจ๊ป ์ฌ์ฉํ๋ค.
to ๋ค์์๋ ๋ฐฉํฅ์ ๋ํ๋ด๋ ์์ฝ์ด๋ฅผ ์ต๋ 2๊ฐ๊น์ง ์ฌ์ฉํ ์ ์๋ค.
์ด๋ ์์ฝ์ด๋ ์ํ ๋ฐฉํฅ์ ๋ํ๋ด๋ left์ right, ์์ง ๋ฐฉํฅ์ ๋ํ๋ด๋ top๊ณผ bottom์ ์ฌ์ฉํ๋ค.
์๋ฅผ ๋ค์ด ์์์ด ์ผ์ชฝ์์ ์ค๋ฅธ์ชฝ์ผ๋ก ๋ณํ๋ ๊ทธ๋ผ๋ฐ์ด์ ์ด๋ผ๋ฉด to right๋ก ์ฌ์ฉํ๋ค. ๊ทธ๋ฆฌ๊ณ ์ผ์ชฝ ์๋์์ ์ค๋ฅธ์ชฝ ์๋ก ๋ณํ๋ ๊ทธ๋ผ๋์์ ์ด๋ผ๋ฉด to right top๋๋ to top right๋ก ์ฌ์ฉํ๋ค. ๊ธฐ๋ณธ๊ฐ์ to bottom ์ด๋ค.
๋ค์ ์์ ์์ ๊ทธ๋ผ๋ฐ์ด์ ์ ์ผ์ชฝ ์์์ ์ค๋ฅธ์ชฝ ์๋ ๋ฐฉํฅ์ผ๋ก, ์์์ ํ๋์์์ ์ ์ ํฐ์์ผ๋ก ๋ณํ๋ค. CSS3๋ฅผ ์ง์ํ์ง ์๋ ์น ๋ธ๋ผ์ฐ์ ๋ฅผ ์ํด ๋ฐฐ๊ฒฝ์์ ํ๋์์ผ๋ก ์ ํํ๋ค.
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8">
<title>Html-basic</title>
<style>
.grad {
width: 800px;
height: 450px;
background: blue;
background: linear-gradient(to right bottom, blue, white);
}
</style>
</head>
<body>
<div class="grad"></div>
</body>
</html>
-๊ฐ๋
๊ฐ๋๋ ๊ทธ๋ผ๋ฐ์ด์ ์ด ๋๋๋ ๋ถ๋ถ์ ๋ฐฉํฅ์ deg๋ก ํ์ํด์ฃผ๋ฉด ๋๋ค. 12์๋ฐฉํฅ์ด 0deg, ๊ทธ๋ฆฌ๊ณ ์๊ณ๋ฐฉํฅ์ผ๋ก ๊ทธ ๊ฐ์ด 360๊น์ง ์ปค์ง๋ค.
-์์ ์ค์ง์
2๊ฐ์ง ์ ์ด์์ ์ ํ ๊ทธ๋ผ๋ฐ์ด์ ์ ๋ง๋ค๋ ค๋ฉด ์์์ด ๋ฐ๋๋ ๋ถ๋ถ์ ์ง์ ํด ์ฃผ์ด์ผ ํ๋ค.
๊ทธ๋ผ๋ฐ์ด์ ์์ ๋ฐ๋๋ ์์ ์์ ์ค์ง์ ์ด๋ผ๊ณ ํ๋ค.
์์ ์ค์ง์ ์ ์ง์ ํ ๋ ์ผํ๋ก ์์์ ๊ตฌ๋ถํ๋๋ฐ, ์์๋ง ์ง์ ํ ์๋ ์๊ณ ์์ ์ค์ง์ ๊ณผ ํจ๊ป ์ค์ง์ ์ ์์น๋ ํจ๊ป ์ง์ ํ ์ ์๋ค.
์ค์ง์ ์์น๋ ์์๊ณผ ๊ณต๋ฐฑ์ผ๋ก ๊ตฌ๋ถํ์ฌ ๋ฐฑ๋ถ์จ๋ก ์ ์ด์ฃผ๋ฉด ๋๋ค.
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8">
<title>Html-basic</title>
<style>
.grad {
width: 800px;
height: 450px;
background: blue;
background: linear-gradient(to bottom,purple, navy 10%, blue 40%, skyblue);
}
</style>
</head>
<body>
<div class="grad"></div>
</body>
</html>
์ํ ๊ทธ๋ผ๋ฐ์ด์
์ ํ ๊ทธ๋ผ๋ฐ์ด์ ์ด ์ง์ ํํ๋ก ์์์ด ๋ฐ๋๋ ๊ฑฐ๋ผ๋ฉด, ์ํ ๊ทธ๋ผ๋ฐ์ด์ ์ ์ ๋๋ ํ์์ ์ค์ฌ์์๋ถํฐ ๋์ฌ์์ ๊ทธ๋ฆฌ๋ฉฐ ๋ฐ๊นฅ ๋ฐฉํฅ์ผ๋ก ์์์ด ๋ฐ๋๋ค. ๋ฐ๋ผ์ ์ํ ๊ทธ๋ผ๋ฐ์ด์ ์ ์์์ด ๋ฐ๋๊ธฐ ์์ํ๋ ์์ ์ค์ฌ๊ณผ ํฌ๊ธฐ๋ฅผ ์ง์ ํ๊ณ ๊ทธ๋ผ๋ฐ์ด์ ์ ๋ชจ์์ ์ ํํ๋ค.
radial-gradient(<๋ชจ์> <ํฌ๊ธฐ> at <์์น>, <์์ ์ค์ง์ >, [<์์ ์ค์ง์ >, ... ]);
-๋ชจ์
์ํ(circle)๊ณผ ํ์ํ(ellipse)์ด ์๋ค. ๋ฐ๋ก ์ง์ ํ์ง ์์ผ๋ฉด ํ์ํ์ผ๋ก ์ธ์ํ๋ค.
-ํฌ๊ธฐ
์ํ ๊ทธ๋ผ๋ฐ์ด์ ์ ์ง์ ํ ๋ ์์ ํฌ๊ธฐ๋ ์ง์ ํ ์ ์๋ค.
์์ ๋ชจ์๊ณผ ํฌ๊ธฐ๋ฅผ ๋ํ๋ด๋ ํค์๋๊ฐ์ ํจ๊ป ์ฐ๋ฉด ๋๋ค.
ํฌ๊ธฐ์์ ์ฌ์ฉํ ์ ์๋ ๊ฐ์ ๋ค์๊ณผ ๊ฐ๋ค.
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8">
<title>Html-basic</title>
<style>
.grad {
margin: 20px;
display: inline-block;
width: 300px;
height: 300px;
background: green;
}
#closest-side { background: radial-gradient(circle closest-side at 30% 20%,white, yellow, green); }
#closest-corner { background: radial-gradient(circle closest-corner at 30% 20%,white, yellow, green); }
#farthest-side { background: radial-gradient(circle farthest-side at 30% 20%,white, yellow, green); }
#farthest-corner { background: radial-gradient(circle farthest-corner at 30% 20%,white, yellow, green); }
</style>
</head>
<body>
<div class="grad" id="closest-side"></div>
<div class="grad" id="closest-corner"></div>
<div class="grad" id="farthest-side"></div>
<div class="grad" id="farthest-corner"></div>
</body>
</html>
์์ฑ๊ฐ | ์ค๋ช | ๊ฒฐ๊ณผ ํ๋ฉด |
closest-side | ๊ทธ๋ผ๋ฐ์ด์ ๊ฐ์ฅ์๋ฆฌ ์ค ํ๋๋ง์ด ์์์ ํ ๋ณ์ ๋ฟ์ ํฌ๊ธฐ๋ก ๊ทธ๋ผ๋ฐ์ด์ ์ ๊ทธ๋ฆฝ๋๋ค. | ![]() |
closet-corner | ๊ทธ๋ผ๋ฐ์ด์ ์ ๊ฐ์ฅ์๋ฆฌ ์ค ํ๋๋ง์ด ์์์ ํ ๊ผญ์ง์ ์ ๋ฟ์ ํฌ๊ธฐ๋ก ๊ทธ๋ผ๋ฐ์ด์ ์ ๊ทธ๋ฆฝ๋๋ค. | ![]() |
farthest-side | ๊ทธ๋ผ๋ฐ์ด์ ์ ๊ฐ์ฅ์๋ฆฌ์ค ํ๋๊ฐ ์์์ ํ ๋ณ์ ๋ฟ๊ณ ๋๋จธ์ง๋ ์์๋ฅผ ๋์ด์๋๋ก ๊ทธ๋ผ๋ฐ์ด์ ์ ๊ทธ๋ฆฝ๋๋ค. | ![]() |
farthest-corner | ๊ทธ๋ผ๋ฐ์ด์ ์ ๊ฐ์ฅ์๋ฆฌ์ค ํ๋์ ์์๊ฐ ๊ผญ์ง์ ์ ๋ฟ๊ณ ๋๋จธ์ง๋ ์์๋ฅผ ๋์ด์๋๋ก ๊ทธ๋ผ๋ฐ์ด์ ์ ๊ทธ๋ฆฝ๋๋ค. | ![]() |
-์์น
at ํค์๋์ ํจ๊ป ์ง์ ํ๋ฉด ๊ทธ๋ผ๋ฐ์ด์ ์ด ์์ํ๋ ์์ ์ค์ฌ์ ๋ค๋ฅด๊ฒ ๋ํ๋ผ ์ ์๋ค.
์ฌ์ฉํ ์ ์๋ ์์น ์์ฑ๊ฐ์ ํค์๋ ๋๋ ๋ฐฑ๋ถ์จ์ด๋ค.
์ํ ํค์๋: left, center, right
์์ง ํค์๋: top, center, bottom
์์ ์์์์ at 30% 20%๋ก ๊ทธ๋ผ๋ฐ์ด์ ์ ์ค์ฌ์ ์ค์ ํ์์๋ค.
-์์ ์ค์ง์
์์์ด ๋ฐ๋๋ ๋ถ๋ถ์ ์์ ์ค์ง์ ์ด๋ผ๊ณ ํ๋ค.
์ ๋ค์ ๊ณต๋ฐฑ์ ๋์ฐ๊ณ ๋ฐฑ๋ถ์จ์ ์ ์ด์ฃผ๋ฉด ๋๋ค.
๊ทธ๋ผ๋ฐ์ด์ ์ ์ฌ์ฉํด ํจํด ๋ง๋ค๊ธฐ
์ ํ ๊ทธ๋ผ๋ฐ์ด์ ๊ณผ ์ํ ๊ทธ๋ผ๋ฐ์ด์ ์ ๋ฐ๋ณต์ ์ธ ํจํด์ ๋ง๋ค ์ ์๋ค.
์ ํ ๊ทธ๋ผ๋ฐ์ด์ ์ ๋ฐ๋ณตํ ๋๋ repeating-linear-gradient๋ฅผ ์ฌ์ฉํ๊ณ ,
์ํ ๊ทธ๋ผ๋ฐ์ด์ ์ ๋ฐ๋ณตํ ๋๋ repeating-radial-gradient๋ฅผ ์ฌ์ฉํ๋ค.
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8">
<title>Html-basic</title>
<style>
.block{
margin: 10px;
width: 200px;
height: 200px;
display: inline-block;
}
#grad1
{
background: repeating-linear-gradient(yellow, red 20px);
}
#grad2
{
background: repeating-linear-gradient(yellow,yellow 20px, red 20px, red 40px);
}
#grad3
{
background: repeating-radial-gradient(circle, white, gray 10%);
}
#grad4
{
background: repeating-radial-gradient(circle, white, white 10%, gray 10%, gray 20%);
}
</style>
</head>
<body>
<div class="block" id="grad1"></div>
<div class="block" id="grad2"></div>
<div class="block" id="grad3"></div>
<div class="block" id="grad4"></div>
</body>
</html>