Style Sheet/Bootstrap5

๐Ÿ”ฎ BootStrap5 ๋ฐ˜์‘ํ˜• ์‹œ์Šคํ…œ - ์ค‘๋‹จ์  (๋ฏธ๋””์–ด ์ฟผ๋ฆฌ)

์ธํŒŒ_ 2021. 10. 15. 17:18

์ค‘๋‹จ์ 

์ค‘๋‹จ์  Breakpoints

Breakpoints๋Š” Bootstrap์˜ ๋ฐ˜์‘ํ˜• ๋ ˆ์ด์•„์›ƒ์ด ๋ทฐํฌํŠธ ํฌ๊ธฐ ๋˜๋Š” ๊ธฐ๊ธฐ์—์„œ ์–ด๋–ป๊ฒŒ ์ž‘๋™ ํ• ์ง€ ๊ฒฐ์ •ํ•˜๋Š” ์‚ฌ์šฉ์ž๊ฐ€ ์ •์˜ ๊ฐ€๋Šฅํ•œ ๋„“์ด์ž…๋‹ˆ๋‹ค.

 

Bootstrap์—๋Š” ๋ฐ˜์‘ํ˜• ์ œ์ž‘์„ ์œ„ํ•ด grid tiers ๋ผ๊ณ  ํ•˜๋Š” 6๊ฐœ์˜ Breakpoints๊ฐ€ ํฌํ•จ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

์ด๋Ÿฌํ•œ breakpoints๋Š” Sass ์†Œ์Šค ํŒŒ์ผ์„ ์‚ฌ์šฉํ•  ๊ฒฝ์šฐ ์‚ฌ์šฉ์ž๊ฐ€ ์ง€์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Breakpoint Class infix Dimensions
X-Small None <576px
Small sm ≥576px
Medium md ≥768px
Large lg ≥992px
Extra large xl ≥1200px
Extra extra large xxl ≥1400px

 

์ค‘๋‹จ์ ์€ Sass๋ฅผ ํ†ตํ•ด ์‚ฌ์šฉ์ž ์ •์˜ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. 

_variables.scss ์Šคํƒ€์ผ ์‹œํŠธ์˜ Sass ๋งต์—์„œ ์ฐพ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

$grid-breakpoints: (
  xs: 0,
  sm: 576px,
  md: 768px,
  lg: 992px,
  xl: 1200px,
  xxl: 1400px
);

๋ฏธ๋””์–ด ์ฟผ๋ฆฌ

 

[CSS] ๐Ÿ“š ๋ฏธ๋””์–ด ์ฟผ๋ฆฌ - ๋ฐ˜์‘ํ˜• ๋ ˆ์ด์•„์›ƒ

๋ฏธ๋””์–ด ์ฟผ๋ฆฌ๋Š” CSS์—์„œ ์–ด๋–ค ์Šคํƒ€์ผ์„ ์„ ํƒ์ ์œผ๋กœ ์ ์šฉํ•˜๊ณ  ์‹ถ์„ ๋•Œ ์‚ฌ์šฉํ•œ๋‹ค. โ€‹ @media ํ‚ค์›Œ๋“œ๋กœ ์‹œ์ž‘ํ•˜๋Š” ๋ฏธ๋””์–ด ์ฟผ๋ฆฌ์˜ ๋ฌธ๋ฒ• ๊ตฌ์กฐ๋Š” ์•„๋ž˜์™€ ๊ฐ™๋‹ค. @media (์กฐ๊ฑด) { ์Šคํƒ€์ผ } ์Šคํƒ€์ผ ๋ถ€๋ถ„์—๋Š” ์ผ๋ฐ˜

inpa.tistory.com

Bootstrap์€ ๋ชจ๋ฐ”์ผ ์šฐ์„ ์œผ๋กœ ๊ฐœ๋ฐœ ๋˜์—ˆ์œผ๋ฏ€๋กœ ๋ช‡ ๊ฐ€์ง€ ๋ฏธ๋””์–ด ์ฟผ๋ฆฌ๋ฅผ ์ด์šฉํ•˜์—ฌ ๋ ˆ์ด์•„์›ƒ์— ์ ํ•ฉํ•œ breakpoints๋ฅผ ๋งŒ๋“ญ๋‹ˆ๋‹ค.

 

Min-width

// Small devices (landscape phones, 576px and up)
@media (min-width: 576px) { ... }

// Medium devices (tablets, 768px and up)
@media (min-width: 768px) { ... }

// Large devices (desktops, 992px and up)
@media (min-width: 992px) { ... }

// X-Large devices (large desktops, 1200px and up)
@media (min-width: 1200px) { ... }

// XX-Large devices (larger desktops, 1400px and up)
@media (min-width: 1400px) { ... }

๊ธฐ์กด ๋ฏธ๋””์–ด ์ฟผ๋ฆฌ๋Š” ์ด๋ ‡๊ฒŒ ํ•˜๋‚˜ํ•˜๋‚˜ ์ •ํ•ด์„œ ์จ์คฌ์—ˆ์Šต๋‹ˆ๋‹ค.

ํ•˜์ง€๋งŒ ๋ถ€ํŠธ์ŠคํŠธ๋žฉ์—์„œ ์ด๊ฒƒ๋“ค์„ ๋ชจ๋“ˆํ™”ํ•˜์—ฌ ์ง€์›ํ•ด์ค๋‹ˆ๋‹ค.

/* No media query necessary for xs breakpoint as it's effectively `@media (min-width: 0) { ... } */`
@include media-breakpoint-up(sm) { ... }
@include media-breakpoint-up(md) { ... }
@include media-breakpoint-up(lg) { ... }
@include media-breakpoint-up(xl) { ... }
@include media-breakpoint-up(xxl) { ... }


/* Example: Hide starting at `min-width: 0`, and then show at the `sm` breakpoint */
.custom-class {
  display: none;
}
@include media-breakpoint-up(sm) {
  .custom-class {
    display: block;
  }
}

 

Max-width

/* ๋ถ€ํŠธ์ŠคํŠธ๋žฉ */
@include media-breakpoint-down(sm) { ... }
@include media-breakpoint-down(md) { ... }
@include media-breakpoint-down(lg) { ... }
@include media-breakpoint-down(xl) { ... }
@include media-breakpoint-down(xxl) { ... }

@include media-breakpoint-down(md) {
  .custom-class {
    display: block;
  }
}

/*----------------------------------------*/

/* css */
// X-Small devices (portrait phones, less than 576px)
@media (max-width: 575.98px) { ... }

// Small devices (landscape phones, less than 768px)
@media (max-width: 767.98px) { ... }

// Medium devices (tablets, less than 992px)
@media (max-width: 991.98px) { ... }

// Large devices (desktops, less than 1200px)
@media (max-width: 1199.98px) { ... }

// X-Large devices (large desktops, less than 1400px)
@media (max-width: 1399.98px) { ... }

 

๋‹จ์ผ ์ค‘๋‹จ์ 

/* ๋ถ€ํŠธ์ŠคํŠธ๋žฉ */
@include media-breakpoint-only(xs) { ... }
@include media-breakpoint-only(sm) { ... }
@include media-breakpoint-only(md) { ... }
@include media-breakpoint-only(lg) { ... }
@include media-breakpoint-only(xl) { ... }
@include media-breakpoint-only(xxl) { ... }

/*----------------------------------------*/

/* css */
@media (min-width: 768px) and (max-width: 991.98px) { ... }

 

์ค‘๋‹จ์  ์‚ฌ์ด

/* ๋ถ€ํŠธ์ŠคํŠธ๋žฉ */
@include media-breakpoint-between(md, xl) { ... }

/*----------------------------------------*/

/* css */
@media (min-width: 768px) and (max-width: 1199.98px) { ... }

# Reference

https://getbootstrap.kr/docs/5.0/layout/breakpoints/