Languages
[Edit]
EN

How to round div corners using CSS

0 points
Created by:
James-Z
767

Did you know that you can assign different radiuses of curvature to different edges in an HTML div element?

Today, I'd like to show you how to easily round corners in HTML elements using CSS. 😊

Final effect:

CSS - div with rounded corners example
CSS - div with rounded corners example

There are several ways to round element depending on which corners you want to round.

Round each corner with the same value

Edit

In this solution, we use border-radius property with one value to round each corner of the div with the given value.

Runnable example:

Round diagonally opposite corners

Edit

In this solution, we use border-radius property with two values to round diagonally opposite corners of the div with two different values.

Runnable example:

Round each corner with a different value

Edit

In this solution, we use border-radius property with four values to round each corner of the div with a different value, clockwise.

CSS - rounded corners with different values example
CSS - rounded corners with 4 border-radius property values (clockwise direction)

Runnable example: 

Custom rounded corners

Edit

In this solution, we use border-radius property with three values to round corners of the div in the following way:

  • first value describes top-left corner - 20px radius,
  • second value describes opposite top-right and bottom-left corners - 45px radius,
  • third value describes bottom-right corner - 30px radius.

Runnable example:

You can also manually specify which corner you want to round with given value like this: 

Circle div example

Edit

We can also use border-radius property with percentage values. In this solution I've set the property value to 50% to make a circle div.

Runnable example:

Thanks for reading and see you in the next posts! 😊🔜

Related posts

Edit

References

Edit
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

CSS - Blog posts

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join