DEV Community

Cover image for CSS Neon Animation
Chris Bongers
Chris Bongers

Posted on β€’ Originally published at daily-dev-tips.com

43 16

CSS Neon Animation

Guys! Thank you all πŸ₯³, I've hit a 100 subscribers to my Newsletter and I'm over the moon!

It means a lot to me that people choose to read my articles and subscribe to receive my email every day, from the bottom of my heart: Thank you! 🧁

Therefore I wanted to make a cool 100 subs CSS neon animation to celebrate.

See below for what we'll be building today, this amazing CSS Neon Animation

HTML Structure

As for our HTML we need the following structure:

<div class="container">
  <div class="text">
    <b>100 s<span>u</span>bs</b>
  </div>
</div>
Enter fullscreen mode Exit fullscreen mode

We are going to use the container to center everything and use the span to make a cool neon glitch.

CSS Neon

First we are going to import a cool Google font, which looks like it could be used in Neon letters.

@import url(//fonts.googleapis.com/css?family=Pacifico);
Enter fullscreen mode Exit fullscreen mode

The on to our Neon effect!

.text b {
  font: 400 25vh 'Pacifico';
  letter-spacing: -5px;
  color: #fee;
  text-shadow: 0 0px 10px, 0 0 1em #560a86, 0 0 0.5em #560a86, 0 0 0.1em #560a86,
    0 10px 3px #333;
}
Enter fullscreen mode Exit fullscreen mode

As you see, we are setting our font to be the Google Font, and making it a font-weight of 25vh (25% Viewport Height.

Then we are using the text-shadow to make it show as Neon. We add multiple glow "layers" and end with a dark grey to make it appear thicker.

Note: You can use a cool tool like this for creating text-shadows

CSS Neon Glitch Animation

We added a glitch on the u letter. This is common in Neon, and we can re-create this using CSS Animations.

.text b span {
  animation: flicker linear infinite 2s;
}

@keyframes flicker {
  75% {
    color: inherit;
    text-shadow: inherit;
  }
  76% {
    color: #222;
  }
  77% {
    color: inherit;
    text-shadow: none;
  }
  78% {
    color: inherit;
    text-shadow: inherit;
  }
  79% {
    color: #222;
    text-shadow: none;
  }
  80% {
    color: inherit;
    text-shadow: inherit;
  }
  90% {
    color: #222;
    text-shadow: none;
  }
  90.5% {
    color: inherit;
    text-shadow: inherit;
  }
}
Enter fullscreen mode Exit fullscreen mode

The actual animation is a mix of resetting the color and removing the text-shadow for a split second; this gives it the appeal of flickering.

Thank you for reading, and let's connect!

Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on Facebook or Twitter

Playwright CLI Flags Tutorial

5 Playwright CLI Flags That Will Transform Your Testing Workflow

  • 0:56 --last-failed: Zero in on just the tests that failed in your previous run
  • 2:34 --only-changed: Test only the spec files you've modified in git
  • 4:27 --repeat-each: Run tests multiple times to catch flaky behavior before it reaches production
  • 5:15 --forbid-only: Prevent accidental test.only commits from breaking your CI pipeline
  • 5:51 --ui --headed --workers 1: Debug visually with browser windows and sequential test execution

Learn how these powerful command-line options can save you time, strengthen your test suite, and streamline your Playwright testing experience. Click on any timestamp above to jump directly to that section in the tutorial!

Watch Full Video πŸ“ΉοΈ

Top comments (8)

Collapse
 
norrova profile image
Norro valentin β€’

cyberpunk ambiant look very nice πŸ‘

Collapse
 
dailydevtips1 profile image
Chris Bongers β€’

I sometimes wish I could make these cyberpunk renderings! love the colours 🀩

Collapse
 
tlylt profile image
Liu Yongliang β€’

Futuristic vibeπŸŽ‰πŸŽ‰Congrats

Collapse
 
dailydevtips1 profile image
Chris Bongers β€’

Hi Liu, thanks! Very grateful for this milestone 🀟

Collapse
 
cooljasonmelton profile image
Jason Melton β€’

this is sweet!

Collapse
 
dailydevtips1 profile image
Chris Bongers β€’

Hi Jason, thanks for the love buddy πŸ’™

Collapse
 
moonspwll profile image
Aleksei Kowalski β€’

As a text it's cool, but as animation so-so

Collapse
 
dailydevtips1 profile image
Chris Bongers β€’

Hey Aleksei, thanks! How could we enhance the animation more?
I tried with 2 letters blinking, but it turned out a bit "much"

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

πŸ‘‹ Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay