Home >Web Front-end >CSS Tutorial >Creating a Shooting Star Border Animation with Tailwind CSS
In this blog post, we'll create a captivating "shooting star" border animation using Tailwind CSS. This effect gives a glowing, animated border to an input field that can catch the user's attention—perfect for call-to-action sections like email sign-ups or important notifications.
Before diving into the code, you can check out the live demo of the effect here: View in Tailwind Playground.
The animation is achieved using Tailwind CSS's utility classes and pseudo-elements. We'll use Tailwind's after pseudo-class to create a conic gradient animation that spins around the input field, giving the illusion of a shooting star tracing the border.
Below is the HTML structure and Tailwind CSS classes needed to create this effect:
<div class="flex h-screen bg-black"> <div class="z-10 m-auto overflow-hidden p-0.5"> <div class="after:transparent relative h-14 w-[500px] rounded-md border border-white/50 bg-black after:absolute after:-inset-[1px] after:-z-10 after:h-full after:w-full after:animate-[spin_4s_infinite] after:bg-[conic-gradient(var(--tw-gradient-stops))] after:from-transparent after:from-40% after:via-50% after:to-blue-600 after:to-100%"> <input type="text" placeholder="Join the waitlist, enter your email.." class="h-full w-full bg-transparent px-4 text-lg text-white placeholder:text-white/40 focus:outline-none" /> </div> </div> </div>
<div class="flex h-screen bg-black">
<div class="z-10 m-auto overflow-hidden p-0.5">
<div class="after:transparent relative h-14 w-[500px] rounded-md border border-white/50 bg-black ...">
after:absolute after:-inset-[1px] after:-z-10 after:h-full after:w-full after:animate-[spin_4s_infinite] after:bg-[conic-gradient(var(--tw-gradient-stops))] after:from-transparent after:from-40% after:via-50% after:to-blue-600 after:to-100%">
<input type="text" placeholder="Join the waitlist, enter your email.." class="h-full w-full bg-transparent px-4 text-lg text-white placeholder:text-white/40 focus:outline-none" />
With just a few lines of Tailwind CSS and the power of pseudo-elements, you can create eye-catching effects like this shooting star border animation. This effect is not only aesthetically pleasing but also easy to implement and customize for your own projects. Feel free to tweak the colors, timing, and other properties to fit your design needs!
Happy coding!
Cover Photo by Juskteez Vu on Unsplash
The above is the detailed content of Creating a Shooting Star Border Animation with Tailwind CSS. For more information, please follow other related articles on the PHP Chinese website!