HTML & CSS

Border Radius (Rounded Corners) in bootstrap 5 with examples

Description:

Bootstrap 5 is a popular front-end web development framework that provides many useful features and tools to create responsive, modern web applications. One of these features is the ability to create rounded corners on various HTML elements using the border-radius utility class.




Creating Rounded Corners Using Bootstrap 5

To create rounded corners in Bootstrap 5, you need to use the border-radius utility class. This class can be applied to any HTML element that has a border, such as a div, button, or input field.

The basic syntax of the border-radius class is as follows:

Here, {value} is the size of the rounded corners in pixels or a predefined value such as sm, md, or lg.

For example, if you want to create small rounded corners on a div element, you can use the following code:

Similarly, if you want to create medium-rounded corners on a button element, you can use the following code:

You can also create large rounded corners by using the rounded-lg class.



Customizing the Border Radius Values

If you want to customize the size of the rounded corners, you can use the rounded-{side}-{value} class. Here, {side} can be top, bottom, start, or end, and {value} is the size of the rounded corners in pixels or a predefined value.

For example, if you want to create small rounded corners on the top-left and bottom-right corners of a div element, you can use the following code:

Similarly, if you want to create large rounded corners on the top and bottom sides of a button element, you can use the following code:

Creating rounded corners using Bootstrap 5 is easy and straightforward. By using the border-radius utility class, you can add rounded corners to various HTML elements in your web application. Whether you want small, medium, or large rounded corners, Bootstrap 5 provides predefined values that you can use. You can also customize the size of the rounded corners using the rounded-{side}-{value} class. With these options, you can create beautiful, modern web applications with rounded corners that look great on any device.



How to Make Rounded Corners (Border Radius) in Bootstrap

To create a rounded corners effect , Bootstrap provides several classes. Here’s the list:

  • .rounded
  • .rounded-top
  • .rounded-end
  • .rounded-bottom
  • .rounded-start
  • .rounded-circle
  • .rounded-pill

Class .rounded is used to create a rounded corners effect on all 4 corners.

Class .rounded-top is used to create a rounded corners effect in both upper corners, namely the upper left and upper right corners.

Class .rounded-end is used to create a rounded corners effect in both right corners, namely the upper right and lower right corners.

Class .rounded-bottom is used to create a rounded corners effect in both lower corners, namely the lower left and lower right corners.

Class .rounded-start is used to create a rounded corners effect in both left corners, namely the upper left and lower left corners.

Class is .rounded-circle used to create a circle effect.

Class .rounded-pill is used to make a pill effect or rounded on both sides. Requirements for this class element must be rectangular, otherwise, the effect will be the same as .rounded-circle.



The following is an example of using these 7 classes:

Create a Border Radius (Rounded Corners) in bootstrap




Set the Curvature Radius

Internally, Bootstrap uses a 0.25rem radius for every corner, except for classes that use a 50%.rounded-circle radius.

If we want to adjust the radius of curvature, 4 advanced classes are available:

  • .rounded-0
  • .rounded-1
  • .rounded-2
  • .rounded-3

Class .rounded-0 is used to delete the existing border radius, while class .rounded-1, .rounded-2, and is .rounded-3 are used to create a border radius of 0.2rem, 0.25rem, and 0.3rem. Here’s an example of its use:

Create a Border Radius (Rounded Corners) in bootstrap

As can be seen from the display above, the larger the class used, the more rounded the border corners will be.



Thus our tutorial on how to make rounded corners or a border radius using the Bootstrap 5 framework. In my previous article, I explained how to change the background color in Bootstrap 5. Next, we will continue with material on how to create a shadow or shadow effect in Bootstrap 5.

 

Related Articles

Leave a Reply

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

Back to top button