• 회원가입
  • 로그인
  • 구글아이디로 로그인

[css] CSS - paint-order 속성 - SVG 요소나 텍스트 그려지는 순서 지정 (= paint-order속성 = 페인트오더속성)

목차
  1. paint-order 예제 -  SVG 요소나 텍스트 그려지는 순서 지정
  2. paint-order 정의
  3. paint-order 구문
  4. paint-order 예제 - 무지개색 그라데이션 사용해 SVG <text> 그리기 순서 변경

 

paint-order 예제 -  SVG 요소나 텍스트 그려지는 순서 지정

 

<style>

svg {border:1px solid silver;}

 

circle {

  paint-order: stroke fill;

}

</style>


<svg width="200" height="200">

  <circle cx="100" cy="100" r="80" stroke="blue" stroke-width="20" fill="pink" />

</svg>

 

결과보기

 

paint-order 정의

 

SVG 요소나 텍스트 요소가 그려지는 순서 지정.

 


 

1.

  • 텍스트 요소 경우, 획(stroke)과 채우기(fill) 순서만 변경 가능. (∵ 마커 적용 불가)
  • 기본적으로, 채우기 (fill) 먼저 한 후, 획(stroke) 그음.

 

2.

  • 기본값: normal
  • 적용대상: 텍스트 요소
  • 상속여부: O
  • 애니가능: X
  • CSS버전: CSS3
  • JS구문: object.style.paintOrder="stroke fill";

 

3.

IE 제외한 주요 최신 브라우저 모두 지원.

(단, Chrome, Opera 경우, 일부 지원)

 

4. MDN paint-order 예제보기

https://developer.mozilla.org/en-US/docs/Web/CSS/paint-order

 

 

paint-order 구문

 

selector {paint-order: normal|one value|two values|three values|initial|inherit;}

 


[속성값]

 

normal

fill, stroke, markers 순으로 그리기 진행. (기본값)

 

one value

지정값으로 그리기 시작 후, 기본값 순서로 나머지 그리기 진행.

  • (예) "stroke" 지정 시, 다음 순서는 fill, marker 순으로 진행.

 

three values

지정값으로 그리기 시작 후, 기본값 순서로 나머지 페인팅 진행함. 

  • (예) "stroke markers" 지정 시, 다음 순서는 fill 단계 진행.

 

three values

지정 값 순서대로 그리기 진행.

(예) "markers stroke fill" 지정 시, 이 순서대로 진행.

 

initial

이 속성의 기본값 사용.

 

inherit

부모요소의 속성값 상속.

 

 

paint-order 예제 - 무지개색 그라데이션 사용해 SVG <text> 그리기 순서 변경

 

<style> 

text {

  font-size: 80px;

  font-weight: bold;

  paint-order: stroke fill;

}

</style>


<svg width="100%" height="150">

  <defs>

    <linearGradient id="rainbow" x1="0%" y1="0%" x2="100%" y2="0%">

      <stop offset="0%" style="stop-color:#ef5350;stop-opacity:1" />

      <stop offset="25%" style="stop-color:#7e57c2;stop-opacity:1" />

      <stop offset="50%" style="stop-color:#26c6da;stop-opacity:1" />

      <stop offset="75%" style="stop-color:#eeff41;stop-opacity:1" />

      <stop offset="100%" style="stop-color:#ff5722;stop-opacity:1" />

    </linearGradient>

  </defs>

  <text x="30" y="80" id="hz" fill="url(#rainbow)" stroke="purple" stroke-width="10">Homzzang.com</text>

</svg>

 

결과보기

PS. 색상값 약간 다르게 한 버전


분류 제목
box CSS - margin-inline 속성 - 인라인방향 양쪽 끝 바깥 여백 주기 (= margin-inlin…
scroll CSS - scroll-margin-right 속성 -
border CSS - border-block-start-width 속성 -
border CSS - border-inline-style 속성 -
css CSS - rotate 속성 - 요소 회전 (= rotate속성 = 로테이트속성)
scroll CSS - scroll-margin-inline-end 속성 -
scroll CSS - scroll-padding-left 속성 -
scroll CSS - scroll-margin-block-start 속성 -
border CSS - border-inline-color 속성 -
css CSS - break-before 속성 - 지정요소 앞에서 (페이지중단/컬럼중단/영역중단) 발생 여부 지정 …
border CSS - border-start-start-radius 속성 -
css CSS - offset-path 속성 -
scroll CSS - scroll-margin-block-end 속성 -
css CSS - hyphens 속성 - 긴 텍스트 단어에서 하이픈 표시 방법 지정 (= hyphens속성 = 하이…
border CSS - border-block-end-width 속성 - 블락방향 끝테두리 너비(=두께) 지정 (= bo…
border CSS - border-inline-start-width 속성 -
css CSS - place-self 속성 - 그리드셀 내 개별 아이템 (수직/수평) 정렬 (= place-self…
scroll CSS - scroll-snap-stop 속성 -
scroll CSS - scroll-snap-align 속성 -
font CSS - font-kerning 속성 - 문자 모양 고려해, 문자 사이 간격 지정 (= font-kerni…
6/27
목록
찾아주셔서 감사합니다. Since 2012