Style Sheet/Bootstrap5

๐Ÿ”ฎ BootStrap5 ํด๋ž˜์Šค ์ด๋ฆ„ ์ตํ˜€๋ณด๊ธฐ

์ธํŒŒ_ 2021. 10. 19. 09:47

๋ถ€ํŠธ์ŠคํŠธ๋žฉ-ํด๋ž˜์Šค

๋ถ€ํŠธ์ŠคํŠธ๋žฉ ํด๋ž˜์Šค๋ช… ์ด์ •๋ฆฌ

 

์ค‘๋‹จ์  ํด๋ž˜์Šค๋ช…

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

 

width / height

// width
.w-25 == width: 25%
-25, 50, 75, 100, auto

// height
.h-50 == height: 50%

// max-width
.mw-40

// max-height
.mh-100

// viewport
min-vw-100
min-vh-100
vw-100
vh-100

 

ํ…์ŠคํŠธ ์ƒ‰์ƒ

// ํ…์ŠคํŠธ ์ƒ‰์ƒ
.text-primary, white, muted, ...

 

ํ…์ŠคํŠธ ์ •๋ ฌ

// ๊ฐ€๋กœ ์ •๋ ฌ
.text-start, end, center

// ๋ฐ˜์‘ํ˜• ์ •๋ ฌ
text-sm-start, ...

 

ํ…์ŠคํŠธ ์ค„๋ฐ”๊ฟˆ

// ๊ฐ•์ œ ์ค„๋ฐ”๊ฟˆ
.text-wrap

// ์˜ค๋ฒ„ํ”Œ๋กœ์šฐ (ํ…์ŠคํŠธ ๋ฐ•์Šค๋ณด๋‹ค ๋‚ด์šฉ๋ฌผ์ด ๋„˜์ณ๋„ ๊ทธ๋Œ€๋กœ ์ถœ๋ ฅ)
.text-nowrap

// ์ž๋™ ์ค„๋ฐ”๊ฟˆ (ํ…์ŠคํŠธ ๋ฐ•์Šค๋ณด๋‹ค ๋‚ด์šฉ๋ฌผ์ด ๋„˜์น˜๋ฉด ์ž๋™ ๊ฐœํ–‰)
.text-break

 

ํ…์ŠคํŠธ ๋Œ€์†Œ๋ฌธ์ž

.text-lowercase, uppercase, capitalize

 

ํฐํŠธ ํฌ๊ธฐ

.fs-1 ~ 6

 

ํฐํŠธ ์†์„ฑ

๋ถ€ํŠธ์ŠคํŠธ๋žฉ-ํด๋ž˜์Šค
๋ถ€ํŠธ์ŠคํŠธ๋žฉ-ํด๋ž˜์Šค

 

ํ…์ŠคํŠธ ํ–‰ ์‚ฌ์ด ๊ฐ„๊ฒฉ (ํ–‰๊ฐ„)

// line-height
.lh-1
.lh-sm
.lh-base
.lh-lg

 

margin / padding

// ์ผ๋ฐ˜
{property}{sides}-{size}
.mt-0
.ms-1
.p-3

// ๋ฐ˜์‘ํ˜•
{property}{sides}-{breakpoint}-{size}
.me-md-2

{property}

  • m - margin
  • p - padding

{sides}

  • t - mt = margin-top / pt = padding-top
  • b - mb = margin-bottom / pb = padding-bottom
  • s - ms = margin-left / ps = padding-left (RTL์—์„œ๋Š” ๋ฐ˜๋Œ€)
  • e - me = margin-right / ps = padding-right (RTL์—์„œ๋Š” ๋ฐ˜๋Œ€) (์•„๋‹ˆ l์ด๋‚˜ r๋กœ ํ•˜๋ฉด๋˜์ง€ ์™œ s,e๋กœ ํ–ˆ๋Œ€...)
  • x - *-left and *-right. ์ฆ‰ ๊ฐ€๋กœ ๋ถ€๋ถ„
  • y - *-top and *-bottom. ์ฆ‰ ์„ธ๋กœ ๋ถ€๋ถ„
  • blank - ๊ทธ๋ƒฅ m๋˜๋Š” p๋งŒ ์“ฐ๋ฉด 4๋ฐฉํ–ฅ ์ง€์ •

{size}

  • 0 - for classes that eliminate the margin or padding by setting it to 0
  • 1 - (by default) for classes that set the margin or padding to $spacer * .25
  • 2 - (by default) for classes that set the margin or padding to $spacer * .5
  • 3 - (by default) for classes that set the margin or padding to $spacer
  • 4 - (by default) for classes that set the margin or padding to $spacer * 1.5
  • 5 - (by default) for classes that set the margin or padding to $spacer * 3
  • auto - margin to auto

 

์ค‘์•™ ์ •๋ ฌ 

<div class="mx-auto" style="width: 200px;">
  Centered element
</div>

 

border

// ํ…Œ๋‘๋ฆฌ ๋ฐฉํ–ฅ
.border-top, end, bottom, start 

// ํ…Œ๋‘๋ฆฌ ์ƒ‰์ƒ
.border-primary, white, ...

// ํ…Œ๋‘๋ฆฌ ๋‘๊ป˜
.border-1 ~ 6

// ํ…Œ๋‘๋ฆฌ ๋‘ฅ๊ทผ ๋ชจ์„œ๋ฆฌ ํ˜•ํƒœ
.rounded-top, circle, pill, ...

// ํ…Œ๋‘๋ฆฌ ๋‘ฅ๊ทผ ๋ชจ์„œ๋ฆฌ ํฌ๊ธฐ
.rounded-0 ~ 3

 

background

// ๋ฐฐ๊ฒฝ์ƒ‰
.bg-primary, white, ...

// ๋ฐฐ๊ฒฝ ๊ทธ๋ผ๋ฐ์ด์…˜
.bg-gradient

 

display

// xsํฌ๊ธฐ ์—์„œ๋งŒ ์ ์šฉ
.d-{value}
.d-inline-block
.d-grid

// ์ค‘๋‹จ์  ๋ช…์‹œ
.d-{breakpoint}-{value}
.d-lg-block

/* value ๊ฐ’ */
none
inline
inline-block
block
grid
table
table-cell
table-row
flex
inline-flex

 

๋ฐ˜์‘ํ˜• ์š”์†Œ ์ˆจ๊ธฐ๊ธฐ

Screen size Class
Hidden on all .d-none
Hidden only on xs .d-none .d-sm-block
Hidden only on sm .d-sm-none .d-md-block
Hidden only on md .d-md-none .d-lg-block
Hidden only on lg .d-lg-none .d-xl-block
Hidden only on xl .d-xl-none .d-xxl-block
Hidden only on xxl .d-xxl-none
Visible on all .d-block
Visible only on xs .d-block .d-sm-none
Visible only on sm .d-none .d-sm-block .d-md-none
Visible only on md .d-none .d-md-block .d-lg-none
Visible only on lg .d-none .d-lg-block .d-xl-none
Visible only on xl .d-none .d-xl-block .d-xxl-none
Visible only on xxl .d-none .d-xxl-block

 

์ธ์‡„ํ•  ๋•Œ ํ‘œ์‹œ ์—ฌ๋ถ€

 : ์ธ์‡„ํ™”๋ฉด์—์„œ ์ธ์‡„๋ฒ„ํŠผ์ด ๋ณด์ด๋ฉด ์•ˆ๋˜๋‹ˆ๊นŒ, ๊ทธ๋Ÿฐ๊ฑธ ์ˆจ๊ธธ ๋•Œ ์‚ฌ์šฉ

.d-print-none, inline, grid, ...
<div class="d-print-none">Screen Only (Hide on print only)</div>
<div class="d-none d-print-block">Print Only (Hide on screen only)</div>
<div class="d-none d-lg-block d-print-block">Hide up to large on screen, but always show on print</div>

 

float

.float-start, end, none

// ๋ฐ˜์‘ํ˜•
.float-sm-start, ...

 

user-select

 : ํ…์ŠคํŠธ ๋ณต์‚ฌ ๋“œ๋ž˜๊ทธ

.user-select-all, auto, none

 

pointer events

 : ํŠน์ • ์š”์†Œ์—์„œ์˜ ํด๋ฆญ ์ด๋ฒคํŠธ๋ฅผ ๋™์ž‘ํ•˜์ง€ ์•Š๋„๋ก ์ œ์–ด

 

[CSS] ๐Ÿ“š pointer-events : ํด๋ฆญ ์ด๋ฒคํŠธ ๋ฐฉ์ง€

pointer-events css๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํด๋ฆญ์ด๋ฒคํŠธ๋ฅผ ์ œ์–ดํ•  ์ˆ˜ ์žˆ์„๊นŒ์š”? ๊ทธ ๋ฐฉ๋ฒ• ์ค‘ ํ•˜๋‚˜๊ฐ€ ๋ฐ”๋กœ CSS ํ”„๋กœํผํ‹ฐ์ธ pointer-events์ž…๋‹ˆ๋‹ค. ์ด ํ”„๋กœํผํ‹ฐ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ํŠน์ • ์š”์†Œ์—์„œ์˜ ํด๋ฆญ ์ด๋ฒคํŠธ๋ฅผ ๋™์ž‘ํ•˜์ง€ ์•Š

inpa.tistory.com

pe-none, auto

 

overflow

๋ถ€ํŠธ์ŠคํŠธ๋žฉ-ํด๋ž˜์Šค

 

๋ณด์ด๊ธฐ/์ˆจ๊ธฐ๊ธฐ

.visible
.invisible

 

๊ทธ๋ฆผ์ž

๋ถ€ํŠธ์ŠคํŠธ๋žฉ-ํด๋ž˜์Šค

 

position

// position : ์†์„ฑ
position-static
position-relative
position-absolute
position-fixed>
position-sticky

 

top, left, right, bottom

top-0, 50, 100
start-0, 50, 100

property :

  • top - top position
  • start - left position (in LTR)
  • bottom - bottom position
  • end - right position (in LTR)

position :

  • 0 - for 0 edge position
  • 50 - for 50% edge position
  • 100 - for 100% edge position

๋ถ€ํŠธ์ŠคํŠธ๋žฉ-ํด๋ž˜์Šค

 

translate

top-50 start-50 ์œผ๋กœ ํ•˜๋ฉด ์ค‘์•™์œผ๋กœ ๊ฐˆ๊ฒƒ ๊ฐ™์ง€๋งŒ, ์ค‘์•™์—์„œ ์‚ด์ง ์–ด๊ธ‹๋‚˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

translate ํด๋ž˜์Šค๋ฅผ ์“ฐ๋ฉด ์ •ํ™•ํžˆ ์ค‘์•™์œผ๋กœ ์ •๋ ฌ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

// ์š”์†Œ ์ค‘์•™ ๋ฐฐ์น˜
.translate-middle

// ์š”์†Œ๋ฅผ ๊ฐ€๋กœ ๋˜๋Š” ์„ธ๋กœ ๋ฐฉํ–ฅ์œผ๋กœ ์ค‘์•™ ๋ฐฐ์น˜
.translate-middle-x
.translate-middle-y

๋ถ€ํŠธ์ŠคํŠธ๋žฉ-ํด๋ž˜์Šค

 

flex

// display: flex;
.d-flex
.d-inline-flex

// ๋ฐ˜์‘ํ˜•
.d-sm-inline-flex
.d-xxl-inline-flex

 

๋ฐฉํ–ฅ

// flex-direction
.flex-row
.flex-row-reverse
.flex-column
.flex-column-reverse

// ๋ฐ˜์‘ํ˜•
.flex-sm-row
.flex-md-column
...

 

์ „์ฒด ์ •๋ ฌ

// ๊ฐ€๋กœ ์ •๋ ฌ
.justify-content-start
.justify-content-end
.justify-content-center
.justify-content-between
.justify-content-around
.justify-content-evenly

// ์„ธ๋กœ ์ •๋ ฌ
.align-content-start
.align-content-end
.align-content-center
.align-content-around
.align-content-stretch

// ๋ฐ˜์‘ํ˜•
...

 

์•„์ดํ…œ ์ •๋ ฌ

// ํ•œ์ค„ ์„ธ๋กœ ์ •๋ ฌ
.align-items-start
.align-items-end
.align-items-center
.align-items-baseline
.align-items-stretch

// ์•„์ดํ…œ ํ•˜๋‚˜ ์„ธ๋กœ ์ •๋ ฌ
.align-self-start
.align-self-end
.align-self-center
.align-self-baseline
.align-self-stretch

// ๋ฐ˜์‘ํ˜•
...

 

์ฑ„์šฐ๊ธฐ

์ผ๋ จ์˜ ํ˜•์ œ ์š”์†Œ์— .flex-fill ํด๋ž˜์Šค๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ๋ชจ๋“  ๊ฐ€๋กœ ๊ณต๊ฐ„์„ ์ฐจ์ง€ํ•˜๋ฉด์„œ ์ฝ˜ํ…์ธ ์™€ ๋™์ผํ•œ ๋„ˆ๋น„ (๋˜๋Š” ์ฝ˜ํ…์ธ ๊ฐ€ ํ…Œ๋‘๋ฆฌ ์ƒ์ž๋ฅผ ์ดˆ๊ณผํ•˜์ง€ ์•Š๋Š” ๋„ˆ๋น„)๋กœ ๊ฐ•์ œ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.

.flex-fill

๋ถ€ํŠธ์ŠคํŠธ๋žฉ-ํด๋ž˜์Šค

 

์•„์ดํ…œ ํฌ๊ธฐ

.flex-{grow|shrink}-0
.flex-{grow|shrink}-1

๋ถ€ํŠธ์ŠคํŠธ๋žฉ-ํด๋ž˜์Šค
๋ถ€ํŠธ์ŠคํŠธ๋žฉ-ํด๋ž˜์Šค

 

์ž๋™ ๋งˆ์ง„

Flexbox๋Š” ํ”Œ๋ ‰์Šค ์ •๋ ฌ๊ณผ ์ž๋™์—ฌ๋ฐฑ์„ ํ˜ผํ•ฉํ•  ๋•Œ ๊ฝค ๋ฉ‹์ง„ ์ผ์„ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์•„๋ž˜๋Š” ์ž๋™ ๋งˆ์ง„์„ ํ†ตํ•ด ํ”Œ๋ ‰์Šค ํ•ญ๋ชฉ์„ ์ œ์–ดํ•˜๋Š” ์„ธ ๊ฐ€์ง€ ์˜ˆ์‹œ์ž…๋‹ˆ๋‹ค. ๊ธฐ๋ณธ๊ฐ’ (์ž๋™ ๋งˆ์ง„ ์—†์Œ), ๋‘ ํ•ญ๋ชฉ์„ ์˜ค๋ฅธ์ชฝ์œผ๋กœ ๋ฐ€๊ธฐ ( .me-auto ), ๋‘ ํ•ญ๋ชฉ์„ ์™ผ์ชฝ์œผ๋กœ ๋ฐ€๊ธฐ ( .ms-auto ).

๋ถ€ํŠธ์ŠคํŠธ๋žฉ-ํด๋ž˜์Šค

 

align-items , flex-direction : column , margin-top : auto ๋˜๋Š” margin-bottom : auto๋ฅผ ํ˜ผํ•ฉํ•˜์—ฌ ํ•˜๋‚˜์˜ ํ”Œ๋ ‰์Šค ํ•ญ๋ชฉ์„ ์ปจํ…Œ์ด๋„ˆ์˜ ์ƒ๋‹จ ๋˜๋Š” ํ•˜๋‹จ์œผ๋กœ ์ˆ˜์ง ์ด๋™ ์‹œํ‚ต๋‹ˆ๋‹ค.

๋ถ€ํŠธ์ŠคํŠธ๋žฉ-ํด๋ž˜์Šค

 

์ค„๋ฐ”๊ฟˆ

// flex-wrap
.flex-wrap
.flex-nowrap
.flex-wrap-reverse

// ๋ฐ˜์‘ํ˜•
...

 

์ˆœ์„œ

// ์ˆซ์ž๋กœ ์ˆœ์„œ ์ง€์ •
.order-0 ~ 5

// ๊ฐ๊ฐ order : -1, order : 6 ๊ณผ ๊ฐ™๋‹ค
.order-first
.order-last

// ๋ฐ˜์‘ํ˜•
...

 

๋ฏธ๋””์–ด ๊ฐ์ฒด

๋ถ€ํŠธ์ŠคํŠธ๋žฉ-ํด๋ž˜์Šค
๋ถ€ํŠธ์ŠคํŠธ๋žฉ-ํด๋ž˜์Šค


# Reference

https://getbootstrap.kr/docs/5.0/getting-started/introduction/