DEV Community

Cover image for CSS Funstuff: Animated Halfway Borders
Roland Taylor
Roland Taylor

Posted on

8 1

CSS Funstuff: Animated Halfway Borders

Hi! Been a minute, but I'm back with another CSS tutorial!

This one will be pretty quick, but should give you a great launch point for extrapolating and creating something special.

Now you probably know that you can add borders to specific sides of an element, using, for instance:

.border-top {
    border-top: 1px solid white;
}
Enter fullscreen mode Exit fullscreen mode

Result:

A screenshot of the result of the above code, showing a grey square, showing a thin white border at the top

But what you may not realize, is what happens when you add a very simple additional property: border-radius! Now, maybe this sounds super obvious, but just how cool it is, isn't obvious until you see it in action, so let's do that:

.border-top-round {
    border-radius: 50%;
    border-top: 1px solid white;
}
Enter fullscreen mode Exit fullscreen mode

Result:

A screenshot of the above code, showing a grey circle with a thin, tapered, white border, at the top

Cool, isn't it? No?
Well let's make it so!

Animating it all:

If the first bit wasn't all that impressive, maybe adding a little fun and flare should do the trick.

Check it out!

So what's the code for this one? Grab it here (it's free!):

Source Code

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay