AI CSS Animations

CSS Border Animations

60 CSS border animations: rotating gradient borders, glowing and neon borders, border draws, marching ants, rainbow and snake borders. Each one wraps a plain box, so it works on cards, buttons and inputs.

How to use these border animations

Open any border, copy the HTML and CSS, and put your own content inside the box. The border is drawn with a pseudo-element, a background-clip layer or a mask, so it never changes the box's size or shifts the layout while it animates.

To change the color, set --bdr-color; gradients and glows are mixed from it. To change the size, set --bdr-size: the border width, radius and glow are in em.

Rotating gradient borders animate a registered @property angle, which every current browser supports; older ones show a still gradient border. Every snippet ships with a prefers-reduced-motion rule that stops the motion.

Frequently asked questions

How do I animate a border in CSS?

A border itself can't hold a gradient or move. Draw it with a pseudo-element or a background-clip: border-box layer, then animate its transform, background-position or an @property angle.

How do I make a gradient border with border-radius?

Use two backgrounds with a transparent border: a solid fill clipped to padding-box and the gradient clipped to border-box. For a see-through middle, mask the inside with mask-composite: exclude.

How do I make a rotating gradient border?

Register an angle with @property, use it as the start of a conic-gradient, and animate it from 0deg to 360deg. The rotating entries above are complete.

How do I make a border glow?

Stack box-shadow layers in the accent color for an outer glow and add an inset shadow for an inner glow. Use filter: drop-shadow() for shapes that aren't rectangles.

Does @property work in all browsers?

Yes. It has been supported everywhere since Firefox 128 shipped it in mid 2024. Older browsers ignore the animation and show a static gradient border.