본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

CSS 그림자

원문 보기 위키 갱신

CSS 그림자 (Elevation) (CSS Shadows)

깊이/입체감 효과를 만드는 간단하면서도 효과적인 그림자 추가 방법이에요. 그림자는 Material Design 사양(깊이 24단계)을 따르고 있어요.

출처: 문서

본문

Usage

CSS Class Name Description
no-shadow 모든 그림자를 제거해요
inset-shadow 상단에 inset 그림자 설정
inset-shadow-down 하단에 inset 그림자 설정
shadow-1 깊이 1 설정
shadow-2 깊이 2 설정
shadow-N 여기서 N은 1부터 24까지의 정수예요
shadow-transition 그림자에 기본 CSS 전환 효과를 적용해요

Example "Standard shadows":

<template>
  <div
    class="flex inline shadow-box flex-center"
    v-for="n in 24"
    :key="n"
    :class="`shadow-${n}`"
  >
    .shadow-{{ n }}
  </div>
</template>

<style lang="sass" scoped>
.shadow-box
  width: 90px
  height: 90px
  margin: 25px
  border-radius: 50%
  font-size: 12px
</style>

위 그림자는 요소의 아래쪽을 향해요. 요소의 위쪽을 향하게 하려면 숫자 앞에 up을 추가하세요:

CSS Class Name Description
shadow-up-1 깊이 1 설정
shadow-up-2 깊이 2 설정
shadow-up-N 여기서 N은 1부터 24까지의 정수예요

Example "Shadows pointing up":

<template>
  <div
    class="flex inline shadow-box flex-center"
    v-for="n in 24"
    :key="n"
    :class="`shadow-up-${n}`"
  >
    .shadow-up-{{ n }}
  </div>
</template>

<style lang="sass" scoped>
.shadow-box
  width: 90px
  height: 90px
  margin: 25px
  border-radius: 50%
  font-size: 12px
</style>

Example "Inset shadow":

<template>
  <div class="q-gutter-md">
    <div
      class="inset-shadow flex inline shadow-box flex-center doc-inset-shadow"
    >
      .inset-shadow
    </div>

    <div
      class="inset-shadow-down flex inline shadow-box flex-center doc-inset-shadow"
    >
      .inset-shadow-down
    </div>
  </div>
</template>

<style lang="sass" scoped>
.shadow-box
  width: 90px
  height: 90px
  margin: 25px
  border-radius: 50%
  font-size: 12px
.doc-inset-shadow
  width: 120px
  height: 120px
  border: 1px solid #eee
  padding: 4px
</style>

Shadow color (v2.31+)

그림자 색상은 :root에 선언된 CSS custom property예요: 라이트 모드에서는 --q-shadow-color(기본 #000), 다크 모드에서는 --q-dark-shadow-color(기본 #fff)예요. 이것들을 :root나 body에서 재정의해 모든 그림자를 다시 채색(또는 transparent로 제거)할 수 있어요. 그림자 색조(tint)는 body 수준에서 이것들로부터 파생되므로, DOM 더 깊은 곳에 배치된 재정의는 효과가 없어요.

:root {
  --q-shadow-color: #1a237e;
}

body.body--dark {
  --q-dark-shadow-color: #000;
}

더 알아보기 (Learn more)

Material Design 사양을 따르는 24단계 깊이의 그림자 클래스와, 다크 모드의 그림자 색상 커스터마이징을 다뤄요. 다크 모드 그림자에 대한 자세한 내용은 Dark Mode 문서를 참조하세요.