How to Give Divs Rounded Corners: Beyond the Boxy Look

What happened

Everyone, please move your attention to the side for a moment. You can see that I’ve added borders to the sidebar on my blog to make sections like ‘Recent Posts‘ and ‘Popular Posts‘ more distinct. On the desktop version, it’s on the right-hand side, while on mobile, it might be placed below the articles.

The key point here is that the sharp corners of the borders felt a bit rigid to me. So, after some research, I’ve discovered a new attribute, which is the focus of this discussion – the ‘border-radius‘ property.

border-radius

border-radius is a CSS3 property used to control the rounded corners of elements, allowing you to create various types of rounded corners.

The most basic usage is as follows. Let’s take a look at an example:

See the Pen border-radius_example by story zyra (@story-zyra) on CodePen.

You can see two examples provided above that demonstrate different effects (colors have been adjusted for clarity).

If you set only one value, all four corners will use that number as the radius for rounding.

It also supports multiple values, representing the radii for each corner in a clockwise direction from the top left (in the example, only three values are set to illustrate that if not set, they will be the same as the first one).

Did you notice something? Besides using ‘px,’ you can also use ‘%’ to set the radius, providing greater flexibility.

Set the radius for specific corners

Certainly! However, in this case, you’ll need to use some sibling properties. These include

  • border-top-left-radius
  • border-top-right-radius
  • border-bottom-left-radius
  • border-bottom-right-radius

Conclusion

I’m increasingly in awe of front-end developers with each passing day!

No wonder they can create such beautiful styles. I wonder how many properties I haven’t even used yet…

Reference

🧡 Hopefully, this post has helped you to some extent.

🧡You can support me by clicking some ad, Thanks a lot

If you got any problem about the explanation, please feel free to let me know

Some Random notes

Leave a Reply

Your email address will not be published. Required fields are marked *