Свойство 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сипаттамасы,
ол мәтін контурінің қалыңдығын белгілейді