Properti text-stroke
Properti text-stroke mengatur warna dan ketebalan outline
karakter teks atau outline-nya. Sebagai
nilai, properti perlu diatur dengan
ketebalan outline dan warna outline dipisahkan oleh spasi.
Sintaks
selector {
text-stroke: ketebalan outline dan warnanya;
}
Contoh Dasar
Outline teks sederhana:
<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;
}
:
Hanya Outline
Sekarang mari kita buat warna teks sama dengan warna latar belakang (dalam kasus kami putih). Hasilnya, hanya outline-nya yang tersisa:
<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;
}
:
Outline dengan Gradien
Mari buat outline gradien
dengan menggunakan properti 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;
}
:
Outline Berganda
Efek outline ganda dengan 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;
}
:
Outline yang Dianimasikan
Mari tambahkan animasi perubahan outline:
<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; }
}
:
Lihat Juga
-
properti
text-fill-color,
yang mengatur warna isian untuk karakter teks -
properti
text-stroke-color,
yang mengatur warna outline teks -
properti
text-stroke-width,
yang mengatur ketebalan outline teks