text-stroke 속성
text-stroke 속성은 텍스트 문자의 외곽선 색상과 두께, 즉 외곽선을 지정합니다.
속성 값으로는 외곽선의 두께와 색상을 공백으로 구분하여 지정해야 합니다.
구문
선택자 {
text-stroke: 외곽선 두께와 색상;
}
기본 예제
간단한 텍스트 외곽선:
<div class="stroked-text">
Lorem ipsum dolor sit amet
</div>
.stroked-text {
font-size: 48px;
font-weight: bold;
-webkit-text-stroke: 2px red;
text-stroke: 2px red;
}
:
외곽선만 표시
이제 텍스트 색상을 배경 색상(이 경우 흰색)과 동일하게 만듭니다. 결과적으로 외곽선만 남게 됩니다:
<div class="stroked-text">
Lorem ipsum dolor sit amet
</div>
.stroked-text {
font-size: 48px;
font-weight: bold;
color: white;
-webkit-text-stroke: 2px black;
text-stroke: 2px black;
}
:
그라데이션 외곽선
background-clip 속성을 사용하여
그라데이션 외곽선을 만들어 봅시다:
<div class="gradient-stroke">
Lorem ipsum dolor sit amet
</div>
.gradient-stroke {
font-size: 42px;
font-weight: bold;
background: linear-gradient(to right, #ff8a00, #e52e71);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
-webkit-text-stroke: 1px #333;
text-stroke: 1px #333;
}
:
다중 외곽선
text-shadow를 사용한 이중 외곽선 효과:
<div class="double-stroke">
Lorem ipsum dolor sit amet
</div>
.double-stroke {
font-size: 40px;
color: white;
-webkit-text-stroke: 3px #000;
text-stroke: 3px #000;
text-shadow:
0 0 5px #000,
0 0 10px #000;
}
:
애니메이션 외곽선
외곽선 변경 애니메이션을 추가해 봅시다:
<div class="animated-stroke">
Lorem ipsum dolor sit amet
</div>
.animated-stroke {
font-size: 38px;
color: white;
-webkit-text-stroke: 1px #ff0000;
text-stroke: 1px #ff0000;
animation: pulse 2s infinite;
}
@keyframes pulse {
0% { -webkit-text-stroke: 1px #ff0000; text-stroke: 1px #ff0000; }
50% { -webkit-text-stroke: 3px #ff0000; text-stroke: 3px #ff0000; }
100% { -webkit-text-stroke: 1px #ff0000; text-stroke: 1px #ff0000; }
}
:
함께 보기
-
텍스트 문자의 채우기 색상을 지정하는 속성
text-fill-color, -
텍스트 외곽선 색상을 지정하는 속성
text-stroke-color, -
텍스트 외곽선 두께를 지정하는 속성
text-stroke-width,