GRID GARDEN

daymoon_ยท2022๋…„ 2์›” 2์ผ
0

CSS

๋ชฉ๋ก ๋ณด๊ธฐ
3/18
post-thumbnail
post-custom-banner

GRID GARDEN?

๐Ÿค” ๋ฌธ์ œ ๋งํฌ : GRID GARDEN

CSS ์ฝ”๋“œ๋กœ ๋‹น๊ทผ๋ฐญ ๊ฐ€๊พธ๊ธฐ


๐Ÿ“‘ ๋‹ต์•ˆ

๐Ÿฅ• ๋‹จ๊ณ„ 1

#garden {
  display: grid;
  grid-template-columns: 20% 20% 20% 20% 20%;
  grid-template-rows: 20% 20% 20% 20% 20%;
}

#water {
	grid-column-start: 3;
}


๐Ÿฅ• ๋‹จ๊ณ„ 2

#garden {
  display: grid;
  grid-template-columns: 20% 20% 20% 20% 20%;
  grid-template-rows: 20% 20% 20% 20% 20%;
}

#poison {
  grid-column-start: 5;
}


๐Ÿฅ• ๋‹จ๊ณ„ 3

#garden {
  display: grid;
  grid-template-columns: 20% 20% 20% 20% 20%;
  grid-template-rows: 20% 20% 20% 20% 20%;
}

#water {
  /* ์ˆ˜์ง์„ ์„ ๊ธฐ์ค€์œผ๋กœ! */
  grid-column-start: 1;
  grid-column-end: 4;
}


๐Ÿฅ• ๋‹จ๊ณ„ 4

#garden {
  display: grid;
  grid-template-columns: 20% 20% 20% 20% 20%;
  grid-template-rows: 20% 20% 20% 20% 20%;
}

#water {
  /* ์ˆ˜์ง์„ ์„ ๊ธฐ์ค€์œผ๋กœ! */
  grid-column-start: 5;
  grid-column-end: 2;
}


๐Ÿฅ• ๋‹จ๊ณ„ 5

#garden {
  display: grid;
  grid-template-columns: 20% 20% 20% 20% 20%;
  grid-template-rows: 20% 20% 20% 20% 20%;
}

#water {
  /* ์ˆ˜์ง์„ ์„ ๊ธฐ์ค€์œผ๋กœ ์˜ค๋ฅธ์ชฝ์€ -1 -2 -3... ์œผ๋กœ ์ง€์ •๋œ๋‹ค. */
  grid-column-start: 1;
  grid-column-end: -2;
}


๐Ÿฅ• ๋‹จ๊ณ„ 6

#garden {
  display: grid;
  grid-template-columns: 20% 20% 20% 20% 20%;
  grid-template-rows: 20% 20% 20% 20% 20%;
}

#poison {
	grid-column-start:4;
}


๐Ÿฅ• ๋‹จ๊ณ„ 7

#garden {
  display: grid;
  grid-template-columns: 20% 20% 20% 20% 20%;
  grid-template-rows: 20% 20% 20% 20% 20%;
}

#water {
  grid-column-start: 2;
  grid-column-end: span 2;
}


๐Ÿฅ• ๋‹จ๊ณ„ 8

#garden {
  display: grid;
  grid-template-columns: 20% 20% 20% 20% 20%;
  grid-template-rows: 20% 20% 20% 20% 20%;
}

#water {
  grid-column-start: 1;
  grid-column-end:6;
}


๐Ÿฅ• ๋‹จ๊ณ„ 9

#garden {
  display: grid;
  grid-template-columns: 20% 20% 20% 20% 20%;
  grid-template-rows: 20% 20% 20% 20% 20%;
}

#water {
  grid-column-start: span 3;
  grid-column-end: 6;
}


๐Ÿฅ• ๋‹จ๊ณ„ 10

#garden {
  display: grid;
  grid-template-columns: 20% 20% 20% 20% 20%;
  grid-template-rows: 20% 20% 20% 20% 20%;
}

#water {
  grid-column: 4 / 6;
}


๐Ÿฅ• ๋‹จ๊ณ„ 11

#garden {
  display: grid;
  grid-template-columns: 20% 20% 20% 20% 20%;
  grid-template-rows: 20% 20% 20% 20% 20%;
}

#water {
  grid-column: 2/sapn3;
}


๐Ÿฅ• ๋‹จ๊ณ„ 12

#garden {
  display: grid;
  grid-template-columns: 20% 20% 20% 20% 20%;
  grid-template-rows: 20% 20% 20% 20% 20%;
}

#water {
  grid-row-start: 3;
}


๐Ÿฅ• ๋‹จ๊ณ„ 13

#garden {
  display: grid;
  grid-template-columns: 20% 20% 20% 20% 20%;
  grid-template-rows: 20% 20% 20% 20% 20%;
}

#water {
  grid-row: 3/6;
}


๐Ÿฅ• ๋‹จ๊ณ„ 14

#garden {
  display: grid;
  grid-template-columns: 20% 20% 20% 20% 20%;
  grid-template-rows: 20% 20% 20% 20% 20%;
}

#water {
  grid-column: 2;
  grid-row: 5;
}


๐Ÿฅ• ๋‹จ๊ณ„ 15

#garden {
  display: grid;
  grid-template-columns: 20% 20% 20% 20% 20%;
  grid-template-rows: 20% 20% 20% 20% 20%;
}

#water {
  grid-column: 2/span4;
  grid-row: 1/span5;
}


๐Ÿฅ• ๋‹จ๊ณ„ 15

#garden {
  display: grid;
  grid-template-columns: 20% 20% 20% 20% 20%;
  grid-template-rows: 20% 20% 20% 20% 20%;
}

#water {
  grid-column: 2 / span4;
  grid-row: 1 / span5;
}


๐Ÿฅ• ๋‹จ๊ณ„ 16

#garden {
  display: grid;
  grid-template-columns: 20% 20% 20% 20% 20%;
  grid-template-rows: 20% 20% 20% 20% 20%;
}

#water {
  grid-area: 1 / 2 / 4 / 6;
}


๐Ÿฅ• ๋‹จ๊ณ„ 17

#garden {
  display: grid;
  grid-template-columns: 20% 20% 20% 20% 20%;
  grid-template-rows: 20% 20% 20% 20% 20%;
}

#water-1 {
  grid-area: 1 / 4 / 6 / 5;
}

#water-2 {
	grid-area: 2 / 3 / 5 / 6;
}


๐Ÿฅ• ๋‹จ๊ณ„ 18

  • ํ˜„์žฌ ๋ชจ๋“  ์š”์†Œ์˜ ๊ฐ’์ด 0์œผ๋กœ ์„ธํŒ…๋˜์–ด ์žˆ๋‹ค.
  • order๋Š” ์ž‘์€ ๊ฐ’์—์„œ ํฐ ๊ฐ’์œผ๋กœ ์ถœ๋ ฅํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๋…์— order: 1์„ ์ค€๋‹ค.
  • ์ฆ‰, order: 0์ธ ๋ฌผ์€ ์•ž ๋ถ€๋ถ„์— ๋ฐฐ์น˜๋˜๊ณ  order: 1 ์„ ๊ฐ€์ง„ ๋…์€ ๋ฌผ๋ณด๋‹ค ํฌ๊ธฐ ๋•Œ๋ฌธ์— ๋’ท ๋ถ€๋ถ„์— ๋ฐฐ์น˜๋œ๋‹ค.
  • ๋งŒ์•ฝ ๊ฐ order์— ์ˆœ์„œ๊ฐ€ ์ •ํ•ด์ ธ ์žˆ๋‹ค๋ฉด ๋…์„ order: 5๋กœ ์ง€์ •ํ•ด ์ค€๋‹ค.
#garden {
  display: grid;
  grid-template-columns: 20% 20% 20% 20% 20%;
  grid-template-rows: 20% 20% 20% 20% 20%;
}

.water {
  order: 0;
}

#poison {
  order: 1;
}


๐Ÿฅ• ๋‹จ๊ณ„ 19

#garden {
  display: grid;
  grid-template-columns: 20% 20% 20% 20% 20%;
  grid-template-rows: 20% 20% 20% 20% 20%;
}

.water {
  order: 0;
}

.poison {
  order: -1;
}


๐Ÿฅ• ๋‹จ๊ณ„ 20

#garden {
  display: grid;
  grid-template-columns: 50%;
  grid-template-rows: 20% 20% 20% 20% 20%;
}

#water {
  grid-column: 1;
  grid-row: 1;
}


๐Ÿฅ• ๋‹จ๊ณ„ 21

#garden {
  display: grid;
  grid-template-columns: 12.5%;
  grid-template-rows: 20% 20% 20% 20% 20%;
}

#water {
  grid-column: 1;
  grid-row: 1;
}


๐Ÿฅ• ๋‹จ๊ณ„ 22

์ฐธ๊ณ ์ž๋ฃŒ
Tutorial CSS size: rem, em, px
WATCHA ๊ฐœ๋ฐœ์ง€์‹-px|em|rem

  • CSS์—์„œ ํ…์ŠคํŠธ์˜ ํฌ๊ธฐ, ๋ฐ•์Šค์˜ ํฌ๊ธฐ ๋“ฑ์„ ์ง€์ •ํ•˜๊ธฐ ์œ„ํ•œ ์‚ฌ์ด์ง€๋Š” px, rem, em๋“ฑ์˜ ๋‹จ์œ„๋ฅผ ์ด์šฉํ•œ๋‹ค.
  • px : ํ”ฝ์…€(pixel, px)์€ ํฐํŠธ์™€ HTML์š”์†Œ์˜ ํฌ๊ธฐ๋ฅผ ์ง€์ •ํ•˜๋Š” ํ‘œ์ค€ ๋‹จ์œ„์ด๋‹ค.
  • rem : rem๊ฐ’์€ HTML ๋ฃจํŠธ ์š”์†Œ์˜ font-size๋ฅผ ๊ธฐ์ค€์œผ๋กœ ๊ธ€๊ผด ํฌ๊ธฐ๋ฅผ ํ‘œ์‹œํ•œ๋‹ค.
  • em : ์š”์†Œ์˜ ๋ถ€๋ชจ์— ์ง€์ •ํ•œ ํฌ๊ธฐ์— ๋”ฐ๋ผ ํ•ด๋‹น ์š”์†Œ์˜ ํฌ๊ธฐ ๊ฒฐ์ •ํ•œ๋‹ค.
#garden {
  display: grid;
  /* 1์—ดํฌ๊ธฐ 2์—ดํฌ๊ธฐ 3์—ดํฌ๊ธฐ .... */
  /* 1ํ–‰ํฌ๊ธฐ 2ํ–‰ํฌ๊ธฐ 3ํ–‰ํฌ๊ธฐ .... */
  grid-template-columns: 100px 3em 40%;
  grid-template-rows: 20% 20% 20% 20% 20%;
}


๐Ÿฅ• ๋‹จ๊ณ„ 23

  • fr : fraction, ์ˆซ์ž ๋น„์œจ๋Œ€๋กœ ํŠธ๋ž™์˜ ํฌ๊ธฐ๋ฅผ ๋‚˜๋ˆˆ๋‹ค.
#garden {
  display: grid;
  grid-template-columns: 1fr 5fr;
  grid-template-rows: 20% 20% 20% 20% 20%;
}


๐Ÿฅ• ๋‹จ๊ณ„ 24

  • ํŠธ๋ž™ 1๋ฒˆ๊ณผ 5๋ฒˆ์˜ ํฌ๊ธฐ๋ฅผ 50px๋กœ ๊ณ ์ •ํ•œ๋‹ค.
  • ๋‚˜๋จธ์ง€(ํŠธ๋ž™ 2๋ฒˆ, 3๋ฒˆ, 4๋ฒˆ)๋Š” 1fr๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋‚˜๋จธ์ง€ ๊ณต๊ฐ„์„ ์ฐจ์ง€ํ•œ๋‹ค.
#garden {
  display: grid;
  grid-template-columns: 50px 1fr 1fr 1fr 50px;
  grid-template-rows: 20% 20% 20% 20% 20%;
}

#water {
  grid-area: 1 / 1 / 6 / 2;
}

#poison {
  grid-area: 1 / 5 / 6 / 6;
}


๐Ÿฅ• ๋‹จ๊ณ„ 25

#garden {
  display: grid;
  grid-template-columns: 75px 3fr 2fr;
  grid-template-rows: 100%;
}


๐Ÿฅ• ๋‹จ๊ณ„ 26

  • ๋นˆ ๋•…(์ •์› ์ƒ๋‹จ)์„ 50px๋กœ ๊ณ ์ •
  • ๋ฌผ์ด ์žˆ๋Š” ๋•…(5๋ฒˆ์ถ•~6๋ฒˆ์ถ•)์˜ ๋„ˆ๋น„๋ฅผ 50px๋นผ๊ณ  ์ฑ„์šฐ๊ธฐ ์œ„ํ•ด ๋‚˜๋จธ์ง€ ํ–‰์˜ ๋†’์ด๋ฅผ 0์œผ๋กœ ์„ค์ •ํ•œ๋‹ค.
  • ์ฆ‰, 0์œผ๋กœ ์„ค์ •ํ•œ ํ–‰์€ ๊ณต๊ฐ„ ์ฐจ์ง€๋ฅผ ํ•˜์ง€ ์•Š๊ณ  1fr์„ ์ด์šฉํ•˜์—ฌ 50px์„ ์ œ์™ธํ•œ ๊ณณ์„ ์ฑ„์šด๋‹ค.
#garden {
  display: grid;
  grid-template-columns: 20% 20% 20% 20% 20%;
  grid-template-rows: 50px 0 0 0 1fr;
}

#water {
  /* ๋นˆ ๋•… */
  grid-column: 1 / 6;
  /* ๋ฌผ์ด ์žˆ๋Š” ํ–‰ */
  grid-row: 5 / 6;
}


๐Ÿฅ• ๋‹จ๊ณ„ 27

#garden {
  display: grid;
  grid-template: 60% 60% / 200px;
}

#water {
  grid-column: 1;
  grid-row: 1;
}


๐Ÿฅ• ๋‹จ๊ณ„ 28

  • ๋…์ด ์žˆ๋Š” ๋•… (ํ–‰) : ์ •์› ๋ฐ”๋‹ฅ 50px์„ ์ œ์™ธํ•œ ๋•…์„ 1fr๋ฅผ ์ด์šฉํ•˜์—ฌ ๋น„์œจ์„ ์ฑ„์šด๋‹ค.
  • ๋ฌผ์ด ์žˆ๋Š” ๋•… (์—ด) : 20%๋ฅผ ๋…์œผ๋กœ ์ฑ„์šฐ๊ณ  ๋‚˜๋จธ์ง€๋ฅผ 1fr๋ฅผ ์ด์šฉํ•˜์—ฌ ๋น„์œจ์„ ์ฑ„์šด๋‹ค.
#garden {
  display: grid;
  /* ํ–‰ / ์—ด */
  grid-template: 1fr 50px / 20% 1fr;
}


๐Ÿ—“๏ธ ์ˆ˜์ • ๋ฐ ์ถ”๊ฐ€

โœ… 2022.02.26

  • ์ธ๋„ค์ผ ๋ณ€๊ฒฝ
profile
๋ฏธ์ง€์˜ ๊ณต๊ฐ„๐ŸŒ™
post-custom-banner

0๊ฐœ์˜ ๋Œ“๊ธ€