[CSS] Add gradation effect to your text!

Photo by Gradienta on Unsplash

[CSS] Add gradation effect to your text!

ยท

1 min read

๐Ÿ‘‰ linear-gradient() MDN

๊ธ€์”จ์— ๊ทธ๋ผ๋ฐ์ด์…˜ ํšจ๊ณผ๋„ฃ๊ธฐ ๋ฐฉ๋ฒ•!

  1. ์ผ๋‹จ ์˜ˆ์‹œ๋กœ <h1> tag๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๊ธ€์”จ๋ฅผ ์ž‘์„ฑ
  2. CSS์— ์ƒ์œ„์— background์†์„ฑ์— linear-gradient๋ฅผ ์จ์ฃผ๊ณ  ๊ทธ๋ผ๋ฐ์ด์…˜ ๋ฐฉํ–ฅ(to right)์„ ์จ์ค€ ํ›„ ์›ํ•˜๋Š”์ƒ‰๊น”์„ ๋„ฃ์–ด์ค€๋‹ค.
  3. -webkit-background-clip: text;์„ ์ถ”๊ฐ€! ์ด ๋ถ€๋ถ„์ด ๋ฐ”๋กœ ๊ธ€์”จ์— ์ƒ‰๊น”์„ ๋„ฃ์–ด์ค„ ์ˆ˜ ์žˆ๋‹ค!
  4. color: transparent;๋ฅผ ์ถ”๊ฐ€๋กœ ๋„ฃ์–ด์ค€๋‹ค. image.png
<!--html-->
<h1>์•ˆ๋…•ํ•˜์„ธ์š”! ๋งŒ๋‚˜์„œ ๋ฐ˜๊ฐ‘์Šต๋‹ˆ๋‹ค. ์‹ ๊ธฐํ•˜๋„ค์š”!</h1>
/*css*/
h1 {
    background:linear-gradient(
      to right,
      red,
      orange,
      yellow,
      green,
      blue,
      indigo,
      purple
    );
-webkit-background-clip: text;
  color: transparent;

}

์˜ค์˜ค ๋„ˆ๋ฌด ์‹ ๊ธฐํ•ด! CSS๋Š” ์ด๋Ÿฐ๊ฒŒ ์ •๋ง ์žฌ๋ฏธ์žˆ๋Š”๋“ฏ ๐Ÿค“

ย