Pada pembahasan template Textrim sebelumnnya ada salah satu fitur yang sangat menarik yaitu dengan adanya efek glitch atau grunge. Efek tersebut terdapat di judul blog ketika di sorot dengan mouse (hover). mungkin ada bebarapa yang teman – teman tidak suka dengan efek ini, mungkin bisa membuat pusing atau yang lain, namun selera setiap orang berbeda – beda jadi silakan sesuaikan sendiri dengan keinginan kalian.
Yang membuat ini sangat special adalah efek animasi hanya menggunakan CSS saja, pastinya ringan. Jadi tidak butuh Javascript atau yang lain. Efek ini juga sudah support AMP. Buat kalian belum tahu efek glitch seperti apa, yaitu seperti bayangan yang bergerak dengan cepat, seperti halnya layer tv jadul yang rusak.
Oke langsung saja silakan simak cara berikut ini.
Cara Membuat Efek Glitch dengan CSS di Blog
Efek glitch yang kita akan buat ada 2 yaitu:
- Langsung (Default)
- Ketika disorot (hover)
1. Langsung (Default)
Silakan masukan Code CSS dibawah ini ke dalam pengaturan HTML, diatas </style>
/* Text Glitch (Grunge) Effect by igniel.com */
.ignielGlitch {
color: #000;
position: relative;
animation: ignielGlitch1 2.5s infinite;
-moz-animation: ignielGlitch1 2.5s infinite;
-webkit-animation: ignielGlitch1 2.5s infinite;
-o-animation: ignielGlitch1 2.5s infinite;
}
.ignielGlitch:before, .ignielGlitch:after {
content: attr(data-text);
position: absolute;
left: 0px;
right: 0px;
top: 0px;
bottom: 0px;
}
.ignielGlitch:before {
color: #000;
animation: ignielGlitch2 2.5s infinite;
-moz-animation: ignielGlitch2 2.5s infinite;
-webkit-animation: ignielGlitch2 2.5s infinite;
-o-animation: ignielGlitch2 2.5s infinite;
}
.ignielGlitch:after {
color: #000;
animation: ignielGlitch3 2.5s infinite;
-moz-animation: ignielGlitch3 2.5s infinite;
-webkit-animation: ignielGlitch3 2.5s infinite;
-o-animation: ignielGlitch3 2.5s infinite;
}
@keyframes ignielGlitch1{0% {transform: none;opacity: 1;}7% {transform: skew(-0.5deg, -0.9deg);opacity: 0.75;}10% {transform: none;opacity: 1;}27% {transform: none;opacity: 1;}30% {transform: skew(0.8deg, -0.1deg);opacity: 0.75;}35% {transform: none;opacity: 1;}52% {transform: none;opacity: 1;}55% {transform: skew(-1deg, 0.2deg);opacity: 0.75;}50% {transform: none;opacity: 1;}72% {transform: none;opacity: 1;}75% {transform: skew(0.4deg, 1deg);opacity: 0.75;}80% {transform: none;opacity: 1;}100% {transform: none;opacity: 1;}}
@-webkit-keyframes ignielGlitch1{0% {transform: none;opacity: 1;}7% {transform: skew(-0.5deg, -0.9deg);opacity: 0.75;}10% {transform: none;opacity: 1;}27% {transform: none;opacity: 1;}30% {transform: skew(0.8deg, -0.1deg);opacity: 0.75;}35% {transform: none;opacity: 1;}52% {transform: none;opacity: 1;}55% {transform: skew(-1deg, 0.2deg);opacity: 0.75;}50% {transform: none;opacity: 1;}72% {transform: none;opacity: 1;}75% {transform: skew(0.4deg, 1deg);opacity: 0.75;}80% {transform: none;opacity: 1;}100% {transform: none;opacity: 1;}}
@keyframes ignielGlitch2{0% {transform: none;opacity: 0.25;}7% {transform: translate(-2px, -3px);opacity: 0.5;}10% {transform: none;opacity: 0.25;}27% {transform: none;opacity: 0.25;}30% {transform: translate(-5px, -2px);opacity: 0.5;}35% {transform: none;opacity: 0.25;}52% {transform: none;opacity: 0.25;}55% {transform: translate(-5px, -1px);opacity: 0.5;}50% {transform: none;opacity: 0.25;}72% {transform: none;opacity: 0.25;}75% {transform: translate(-2px, -6px);opacity: 0.5;}80% {transform: none;opacity: 0.25;}100% {transform: none;opacity: 0.25;}}
@-webkit-keyframes ignielGlitch2{0% {transform: none;opacity: 0.25;}7% {transform: translate(-2px, -3px);opacity: 0.5;}10% {transform: none;opacity: 0.25;}27% {transform: none;opacity: 0.25;}30% {transform: translate(-5px, -2px);opacity: 0.5;}35% {transform: none;opacity: 0.25;}52% {transform: none;opacity: 0.25;}55% {transform: translate(-5px, -1px);opacity: 0.5;}50% {transform: none;opacity: 0.25;}72% {transform: none;opacity: 0.25;}75% {transform: translate(-2px, -6px);opacity: 0.5;}80% {transform: none;opacity: 0.25;}100% {transform: none;opacity: 0.25;}}
@keyframes ignielGlitch3{0% {transform: none;opacity: 0.25;}7% {transform: translate(2px, 3px);opacity: 0.5;}10% {transform: none;opacity: 0.25;}27% {transform: none;opacity: 0.25;}30% {transform: translate(5px, 2px);opacity: 0.5;}35% {transform: none;opacity: 0.25;}52% {transform: none;opacity: 0.25;}55% {transform: translate(5px, 1px);opacity: 0.5;}50% {transform: none;opacity: 0.25;}72% {transform: none;opacity: 0.25;}75% {transform: translate(2px, 6px);opacity: 0.5;}80% {transform: none;opacity: 0.25;}100% {transform: none;opacity: 0.25;}}
@-webkit-keyframes ignielGlitch3{0% {transform: none;opacity: 0.25;}7% {transform: translate(2px, 3px);opacity: 0.5;}10% {transform: none;opacity: 0.25;}27% {transform: none;opacity: 0.25;}30% {transform: translate(5px, 2px);opacity: 0.5;}35% {transform: none;opacity: 0.25;}52% {transform: none;opacity: 0.25;}55% {transform: translate(5px, 1px);opacity: 0.5;}50% {transform: none;opacity: 0.25;}72% {transform: none;opacity: 0.25;}75% {transform: translate(2px, 6px);opacity: 0.5;}80% {transform: none;opacity: 0.25;}100% {transform: none;opacity: 0.25;}}
Kalian bisa juga menambahkan pengaturan lain, seperti ukuran font, ketebalan font, jenis font atau yang lain.
Kemudian kita buat element HTML untuk memanggil efek glitch tersebut. Tambahkan class ignielGlitch kedalamnya. Contoh:
<!-- Text Glitch (Grunge) Effect by igniel.com -->
<div class="ignielGlitch" data-text="Textrim">Textrim</div>
~ #000 adalah warna teks, Ketiganya bisa diatur dengan warna yang beda – beda supaya bayangan yang tampil bisa berwarna warni.
Demo Langsung (Default)
2. Ketika di sorot (hover)
Efek glitch akan muncul ketika cursor menyoroti / mendekati tulisan.
Silakan masukan kode CSS dibawah ini ke dalam pengaturan HTML, diatas </style>.
/* Text Glitch (Grunge) Effect on Hover by igniel.com */
.ignielGlitch:hover {
color: #000;
position: relative;
animation: ignielGlitch1 2.5s infinite;
-moz-animation: ignielGlitch1 2.5s infinite;
-webkit-animation: ignielGlitch1 2.5s infinite;
-o-animation: ignielGlitch1 2.5s infinite;
}
.ignielGlitch:hover::before, .ignielGlitch:hover::after {
content: attr(data-text);
position: absolute;
left: 0px;
right: 0px;
top: 0px;
bottom: 0px;
}
.ignielGlitch:hover::before {
color: #000;
animation: ignielGlitch2 2.5s infinite;
-moz-animation: ignielGlitch2 2.5s infinite;
-webkit-animation: ignielGlitch2 2.5s infinite;
-o-animation: ignielGlitch2 2.5s infinite;
}
.ignielGlitch:hover::after {
color: #000;
animation: ignielGlitch3 2.5s infinite;
-moz-animation: ignielGlitch3 2.5s infinite;
-webkit-animation: ignielGlitch3 2.5s infinite;
-o-animation: ignielGlitch3 2.5s infinite;
}
@keyframes ignielGlitch1{0% {transform: none;opacity: 1;}7% {transform: skew(-0.5deg, -0.9deg);opacity: 0.75;}10% {transform: none;opacity: 1;}27% {transform: none;opacity: 1;}30% {transform: skew(0.8deg, -0.1deg);opacity: 0.75;}35% {transform: none;opacity: 1;}52% {transform: none;opacity: 1;}55% {transform: skew(-1deg, 0.2deg);opacity: 0.75;}50% {transform: none;opacity: 1;}72% {transform: none;opacity: 1;}75% {transform: skew(0.4deg, 1deg);opacity: 0.75;}80% {transform: none;opacity: 1;}100% {transform: none;opacity: 1;}}
@-webkit-keyframes ignielGlitch1{0% {transform: none;opacity: 1;}7% {transform: skew(-0.5deg, -0.9deg);opacity: 0.75;}10% {transform: none;opacity: 1;}27% {transform: none;opacity: 1;}30% {transform: skew(0.8deg, -0.1deg);opacity: 0.75;}35% {transform: none;opacity: 1;}52% {transform: none;opacity: 1;}55% {transform: skew(-1deg, 0.2deg);opacity: 0.75;}50% {transform: none;opacity: 1;}72% {transform: none;opacity: 1;}75% {transform: skew(0.4deg, 1deg);opacity: 0.75;}80% {transform: none;opacity: 1;}100% {transform: none;opacity: 1;}}
@keyframes ignielGlitch2{0% {transform: none;opacity: 0.25;}7% {transform: translate(-2px, -3px);opacity: 0.5;}10% {transform: none;opacity: 0.25;}27% {transform: none;opacity: 0.25;}30% {transform: translate(-5px, -2px);opacity: 0.5;}35% {transform: none;opacity: 0.25;}52% {transform: none;opacity: 0.25;}55% {transform: translate(-5px, -1px);opacity: 0.5;}50% {transform: none;opacity: 0.25;}72% {transform: none;opacity: 0.25;}75% {transform: translate(-2px, -6px);opacity: 0.5;}80% {transform: none;opacity: 0.25;}100% {transform: none;opacity: 0.25;}}
@-webkit-keyframes ignielGlitch2{0% {transform: none;opacity: 0.25;}7% {transform: translate(-2px, -3px);opacity: 0.5;}10% {transform: none;opacity: 0.25;}27% {transform: none;opacity: 0.25;}30% {transform: translate(-5px, -2px);opacity: 0.5;}35% {transform: none;opacity: 0.25;}52% {transform: none;opacity: 0.25;}55% {transform: translate(-5px, -1px);opacity: 0.5;}50% {transform: none;opacity: 0.25;}72% {transform: none;opacity: 0.25;}75% {transform: translate(-2px, -6px);opacity: 0.5;}80% {transform: none;opacity: 0.25;}100% {transform: none;opacity: 0.25;}}
@keyframes ignielGlitch3{0% {transform: none;opacity: 0.25;}7% {transform: translate(2px, 3px);opacity: 0.5;}10% {transform: none;opacity: 0.25;}27% {transform: none;opacity: 0.25;}30% {transform: translate(5px, 2px);opacity: 0.5;}35% {transform: none;opacity: 0.25;}52% {transform: none;opacity: 0.25;}55% {transform: translate(5px, 1px);opacity: 0.5;}50% {transform: none;opacity: 0.25;}72% {transform: none;opacity: 0.25;}75% {transform: translate(2px, 6px);opacity: 0.5;}80% {transform: none;opacity: 0.25;}100% {transform: none;opacity: 0.25;}}
@-webkit-keyframes ignielGlitch3{0% {transform: none;opacity: 0.25;}7% {transform: translate(2px, 3px);opacity: 0.5;}10% {transform: none;opacity: 0.25;}27% {transform: none;opacity: 0.25;}30% {transform: translate(5px, 2px);opacity: 0.5;}35% {transform: none;opacity: 0.25;}52% {transform: none;opacity: 0.25;}55% {transform: translate(5px, 1px);opacity: 0.5;}50% {transform: none;opacity: 0.25;}72% {transform: none;opacity: 0.25;}75% {transform: translate(2px, 6px);opacity: 0.5;}80% {transform: none;opacity: 0.25;}100% {transform: none;opacity: 0.25;}}
Untuk pengaturan warna dan kecepatan yang ditandai, tidak ada yang beda, semua sama seperti versi pertama.
Untuk kode HTML nya masih sama, yang ditandai valuenya harus sama denga nisi dari teks dalam elemen div.
<!-- Text Glitch (Grunge) Effect on Hover by igniel.com -->
<div class="ignielGlitch" data-text="Textrim">Textrim</div>
Demo Ketika disorot.
Selesai, Mungkin itu silakan gunakan efek tersebut seperlunya saja, karena jika kebanyakan akan membuat pusing. Sekian dan terima kasih.
Posting Komentar
Posting Komentar