CSS / Reference / background-clip

개요

HTML 요소는 박스(box)로 이루어져 있습니다. 배경 이미지나 배경색을 그 박스 중 어디에 넣을 지 정하는 속성이 background-clip입니다.

  • 기본값 : border-box
  • 상속 : No
  • 애니메이션 : No
  • 버전 : CSS Level 3

문법

background-clip: border-box | padding-box | content-box | initial | inherit
  • border-box : 테두리 영역과 그 안쪽 영역을 채웁니다.
  • padding-box : 안쪽 여백 영역과 그 안쪽 영역을 채웁니다.
  • content-box : 내용 영역과 그 안쪽 영역을 채웁니다.
  • initial : 기본값으로 설정합니다.
  • inherit : 부모 요소의 속성값을 상속받습니다.

예제

  • background-clip 속성 값에 따라 어디를 채우는지를 확인하는 예제입니다.
<!doctype html>
<html lang="ko">
  <head>
    <meta charset="utf-8">
    <title>CSS</title>
    <style>
      div {
        box-sizing: border-box;
        width: 100%;
        margin: 20px 0px;
        padding: 20px;
        border: 10px dotted #dadada;
        background-color: #eeeeee;
      }
      .a {
        background-clip: border-box;
      }
      .b {
        background-clip: padding-box;
      }
      .c {
        background-clip: content-box;
      }
    </style>
  </head>
  <body>
    <p><code>background-clip: border-box;</code></p>
    <div class="a">Lorem Ipsum Dolor</div>
    <p><code>background-clip: padding-box;</code></p>
    <div class="b">Lorem Ipsum Dolor</div>
    <p><code>background-clip: content-box;</code></p>
    <div class="c">Lorem Ipsum Dolor</div>
  </body>
</html>

같은 카테고리의 다른 글
CSS / Reference / background-repeat

CSS / Reference / background-repeat

background-repeat는 배경 이미지의 반복 여부와 반복 방향을 정하는 속성입니다. 기본값 : repeat 상속 : No 애니메이션 : No 버전 : CSS Level 1

CSS / Reference / background-position

CSS / Reference / background-position

background-position은 배경 이미지의 위치를 정하는 속성입니다. 기본값 : 0% 0% 상속 : No 애니메이션 : Yes 버전 : CSS Level 1

CSS / Reference / opacity

CSS / Reference / opacity

opacity로 요소의 투명도를 정할 수 있습니다. 기본값 : 1 상속 : No 애니메이션 : Yes 버전 : CSS Level 3

CSS / Reference / font-weight

CSS / Reference / font-weight

font-weight 속성은 CSS에서 글꼴의 굵기를 지정하는 데 사용됩니다. 텍스트의 가독성을 높이거나 디자인의 강조점을 표현할 때 유용합니다. 기본값 : normal 상속 : Yes 애니메이션 : Yes 버전 : CSS Level 1

CSS / Reference / word-wrap

CSS / Reference / word-wrap

word-wrap은 띄어쓰기가 없는 긴 단어를 어떻게 처리할지 정하는 속성입니다. 기본값 : normal 상속 : Yes 애니메이션 : No 버전 : CSS Level 3

CSS / Reference / empty-cells

CSS / Reference / empty-cells

empty-cells은 표(table)에서 빈 셀의 테두리를 표시할지 말지는 정하는 속성입니다. 기본값 : show 상속 : Yes 애니메이션 : No 버전 : CSS Level 2

CSS / Reference / overflow

CSS / Reference / overflow

overflow는 내용이 요소의 크기를 벗어났을 때 어떻게 처리할지를 정하는 속성입니다. 기본값 : visible 상속 : No 애니메이션 : No 버전 : CSS Level 2

CSS / Reference / font-size

CSS / Reference / font-size

font-size는 글자 크기를 정하는 속성입니다. 기본값 : medium 상속 : Yes 애니메이션 : Yes 버전 : CSS Level 1

CSS / Reference / color

CSS / Reference / color

color로 텍스트의 색을 정합니다. 상속 : Yes 애니메이션 : Yes 버전 : CSS Level 1

CSS / Reference / border-style

CSS / Reference / border-style

border-style은 테두리(border)의 모양을 정하는 속성으로, 다음 속성의 단축 속성입니다. border-top-style border-right-style border-bottom-style border-left-style