border-image
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015년 7월.
시도해 보기
border-image: url("/shared-assets/images/examples/border-diamonds.png") 30;
border-image: url("/shared-assets/images/examples/border-diamonds.png") 30 /
19px round;
border-image: url("/shared-assets/images/examples/border-diamonds.png") 30
fill / 30px / 30px space;
border-image: linear-gradient(#f6b73c, #4d9f0c) 30;
border-image: repeating-linear-gradient(30deg, #4d9f0c, #9198e5, #4d9f0c 20px)
60;
<section id="default-example">
<div id="example-element">This is a box with a border around it.</div>
</section>
#example-element {
width: 80%;
height: 80%;
display: flex;
align-items: center;
justify-content: center;
padding: 50px;
background: #fff3d4;
color: #000;
border: 30px solid;
border-image: url("/shared-assets/images/examples/border-diamonds.png") 30
round;
font-size: 1.2em;
}
border-image는 border-image-source, border-image-slice, border-image-width, border-image-outset, border-image-repeat의 단축 속성입니다. 다른 단축 속성과 마찬가지로, 생략한 속성은 초기값으로 설정됩니다.
참고 :
테두리 이미지를 불러오는데 실패할 경우에 대비해 border-style 속성을 설정해야 합니다. 사실 명세에 따르면 필수로 지정해야 하지만 모든 브라우저가 그렇게 구현하지는 않았습니다.
구문
/* 이미지 | 슬라이스 */
border-image: linear-gradient(red, blue) 27;
/* 이미지 | 슬라이스 | 반복 */
border-image: url("/images/border.png") 27 space;
/* 이미지 | 슬라이스 | 너비 */
border-image: linear-gradient(red, blue) 27 / 35px;
/* 이미지 | 슬라이스 | 너비 | 거리 | 반복 */
border-image: url("/images/border.png") 27 23 / 50px 30px / 1rem round space;
border-image 속성은 아래 나열한 값 중 한 개에서 다섯 개 사이를 사용해 지정할 수 있습니다.
참고 :
만약 border-image-source의 계산값이 none이거나 이미지를 그릴 수 없다면 border-style이 대신 보여집니다.
값
<'border-image-source'>-
원본 이미지.
border-image-source를 참고하세요. <'border-image-slice'>-
이미지를 구역별로 나눌 때 사용할 슬라이스 크기. 네 개 값까지 지정할 수 있습니다.
border-image-slice를 참고하세요. <'border-image-width'>-
테두리 이미지 너비. 네 개 값까지 지정할 수 있습니다.
border-image-width를 참고하세요. <'border-image-outset'>-
테두리 이미지와 요소 외곽의 거리. 네 개 값까지 지정할 수 있습니다.
border-image-outset을 참고하세요. <'border-image-repeat'>-
원본 이미지의 모서리 구역을 테두리의 크기에 맞출 때의 조정 방법. 두 개 값까지 지정할 수 있습니다.
border-image-repeat을 참고하세요.
형식 구문
border-image =
<'border-image-source'> ||
<'border-image-slice'> [ / <'border-image-width'> | / <'border-image-width'>? / <'border-image-outset'> ]? ||
<'border-image-repeat'>
<border-image-source> =
none |
<image>
<border-image-slice> =
[ <number [0,∞]> | <percentage [0,∞]> ]{1,4} &&
fill?
<border-image-width> =
[ <length-percentage [0,∞]> | <number [0,∞]> | auto ]{1,4}
<border-image-outset> =
[ <length [0,∞]> | <number [0,∞]> ]{1,4}
<border-image-repeat> =
[ stretch | repeat | round | space ]{1,2}
<image> =
<url> |
<image()> |
<image-set()> |
<cross-fade()> |
<element()> |
<gradient>
<length-percentage> =
<length> |
<percentage>
<image()> =
image( <image-tags>? [ <image-src>? , <color>?