CSS background

๐Ÿ“„ background

background๋Š” ์ฝ˜ํ…์ธ ์˜ ๋ฐฐ๊ฒฝ์„ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค.

๐Ÿ“„ background์˜ ํ•˜์œ„ ์†์„ฑ

โ–ช background-color

: ๋ฐฐ๊ฒฝ์ƒ‰์„ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค.

โ–ช background-image

: ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€๋ฅผ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค.

background-image: url(์ด๋ฏธ์ง€);

โ–ช background-position

: ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€์˜ ์ดˆ๊ธฐ ์œ„์น˜๋ฅผ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค.

โ–ช background-size

: ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€์˜ ํฌ๊ธฐ๋ฅผ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค.

  • cover: ์ด๋ฏธ์ง€๊ฐ€ ์ฐŒ๊ทธ๋Ÿฌ์ง€์ง€ ์•Š๋Š” ํ•œ๋„ ๋‚ด์—์„œ ์ตœ๋Œ€๋กœ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.
  • contain: ์ด๋ฏธ์ง€๊ฐ€ ์ฐŒ๊ทธ๋Ÿฌ์ง€๊ฑฐ๋‚˜ ์ž˜๋ฆฌ์ง€ ์•Š๋Š” ํ•œ๋„ ๋‚ด์—์„œ ์ตœ๋Œ€๋กœ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.

โ–ช background-repeat

: ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€์˜ ๋ฐ˜๋ณต ๋ฐฉ๋ฒ•์„ ์ •์˜ํ•ฉ๋‹ˆ๋‹ค.

  • no-repeat: ์ด๋ฏธ์ง€๋ฅผ ๋ฐ˜๋ณตํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.(์ด๋ฏธ์ง€๊ฐ€ ์ฝ˜ํ…์ธ ๋ณด๋‹ค ์ž‘์„ ๊ฒฝ์šฐ ํ™œ์šฉ)
div {
  background-image: url(์ด๋ฏธ์ง€);
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

background๋Š” ํ•˜์œ„ ์†์„ฑ์„ ์—ฐ๋‹ฌ์•„ ์ •์˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
๋งค์šฐ ๋‹ค์–‘ํ•˜์—ฌ ์‚ฌ์šฉ์ž๋Š” ์†์„ฑ๊ฐ’์„ ์ •ํ™•ํ•œ ๊ฐ’์œผ๋กœ๋งŒ ์ •์˜ํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.

background: no-repeat url(์ด๋ฏธ์ง€);

Leave a comment