Neon text can add a nice, futuristic touch to any website. I’ve always loved the magic of neon signs and wanted to recreate them using CSS. I thought I’d share some tips on how to do it! In this article, we’re going to take a look at how to add glowing effects to text. We’ll also take a look at various ways to animate the neon signs, all using CSS and keyframes.
Adding a glow effect to text
Codepen Link :- https://codepen.io/bulidwithme/pen/NWpoGEB
<div class="container">
<h1 class="neonText">
Welcome to
</h1>
<h2 class="neonText">Build With Me</h2>
</div>
.neonText {
color: #fff;
text-shadow:
0 0 7px #fff,
0 0 10px #fff,
0 0 21px #fff,
0 0 42px #0fa,
0 0 82px #0fa,
0 0 92px #0fa,
0 0 102px #0fa,
0 0 151px #0fa;
}
/* Additional styling */
body {
font-size: 18px;
background-color: #010a01;
}
h1, h2 {
text-align: center;
font-weight: 400;
}
h1 {
font-size: 4.2rem;
}
h2 {
font-size: 1.8rem;
}
.container {
margin-top: 20vh;
}
Adding a flickering effect to glow text
Codepen Link :- https://codepen.io/bulidwithme/pen/jOBdboX
.neonText {
animation: flicker 1.5s infinite alternate;
color: #fff;
}
h1 {
font-size: 4.2rem;
}
/* Flickering animation */
@keyframes flicker {
0%, 18%, 22%, 25%, 53%, 57%, 100% {
text-shadow:
0 0 4px #fff,
0 0 11px #fff,
0 0 19px #fff,
0 0 40px #0fa,
0 0 80px #0fa,
0 0 90px #0fa,
0 0 100px #0fa,
0 0 150px #0fa;
}
20%, 24%, 55% {
text-shadow: none;
}
}
/* Additional styling */
h2 {
font-size: 1.8rem;
}
.container {
margin-top: 20vh;
}
body {
font-size: 18px;
font-family: "Helvetica Neue", sans-serif;
background-color: #010a01;
}
h1, h2 {
text-align: center;
font-weight: 400;
}
Subtle flicker effect to glow text
Codepen Link :- https://codepen.io/bulidwithme/pen/ExWrPPK
<link href='https://fonts.googleapis.com/css?family=Vibur:400' rel='stylesheet' type='text/css'>
<div class="container">
<h1 class="neonText">
Build with <br> Me
</h1>
</div>
.neonText {
color: #fff;
text-shadow:
0 0 7px #fff,
0 0 10px #fff,
0 0 21px #fff,
0 0 42px #f09,
0 0 82px #f09,
0 0 92px #f09,
0 0 102px #f09,
0 0 151px #f09;
}
/* Additional styling */
body {
font-size: 18px;
font-family: "Vibur", sans-serif;
background-color: #010a01;
}
h1, h2 {
text-align: center;
font-weight: 400;
line-height: 1;
}
h1 {
font-size: 6.2rem;
animation: pulsate 0.11s ease-in-out infinite alternate;
}
h2 {
font-size: 1.8rem;
}
.container {
margin-top: 20vh;
}
@keyframes pulsate {
100% {
text-shadow:
0 0 4px #fff,
0 0 11px #fff,
0 0 19px #fff,
0 0 40px #f09,
0 0 80px #f09,
0 0 90px #f09,
0 0 100px #f09,
0 0 150px #f09;
}
0% {
text-shadow:
0 0 4px #fff,
0 0 10px #fff,
0 0 18px #fff,
0 0 38px #f09,
0 0 73px #f09,
0 0 80px #f09,
0 0 94px #f09,
0 0 140px #f09;
}