Hey Friends, in the last tutorial we had seen the CSS Border Property. There are 4 attributes in CSS border property. We have already discussed the first 3 attributes (color, width, and style). If you haven’t read then read the previous one first then read this tutorial. Now we are going to discuss the CSS Border Radius property. So let’s Begin….
CSS Border Radius Property
This CSS property is used to set the rounded corner of the Html elements. It defines the radius of the element. We can change all four corners of the box with different values. The Value of this property can be defined in percentage and length units. This CSS Property has four attributes. These are:-
- Border-top-left-radius
- Border-top-right-radius
- Border-bottom-left-radius
- Border-bottom-right-radius
Let see an amazing example of it.
Example:-
<html>
<head>
<title> CSS Border Radius Property </title>
<style>
*{
margin: 30px;
}
body{
display: flex;
}
.box{
padding: 23px;
height: 20%;
width: 20%;
border-style: solid;
border-radius: 23%;
}
#box1{
background-color: burlywood;
}
#box2{
background-color: cornflowerblue;
}
#box3{
background-color: darkgray;
}
#box4{
background-color: darkorchid;
}
</style>
</head>
<body>
<p class="box" id="box1"> Box 1</p>
<p class="box" id="box2"> Box 2</p>
<p class="box" id="box3"> Box 3</p>
<p class="box" id="box4"> Box 4</p>
</body>
</html>
Output:-
In this example, you saw how all the corners of the box got rounded. If the user want to corner only the left side of the box. Then you have to select the border-top-left-radius attribute. Now the below example will show you to change all the box corner with different values.
Example:-
<html>
<head>
<title> CSS Border Radius Property </title>
<style>
*{
margin: 30px;
}
body{
display: flex;
}
.box{
padding: 23px;
height: 20%;
width: 20%;
border-style: solid;
}
#box1{
background-color: burlywood;
border-top-left-radius: 20px;
border-top-right-radius: 30px;
border-bottom-left-radius: 40px;
border-bottom-right-radius: 50px;
}
#box2{
background-color: cornflowerblue;
border-top-left-radius: 5px;
border-top-right-radius: 10px;
border-bottom-left-radius: 15px;
border-bottom-right-radius: 20px;
}
#box3{
background-color: darkgray;
border-top-left-radius: 56px;
border-top-right-radius: 72px;
border-bottom-left-radius: 33px;
border-bottom-right-radius: 33px;
}
#box4{
background-color: darkorchid;
border-top-left-radius: 40px;
border-top-right-radius: 35px;
border-bottom-left-radius: 25px;
border-bottom-right-radius: 15px;
}
</style>
</head>
<body>
<p class="box" id="box1"> Box 1</p>
<p class="box" id="box2"> Box 2</p>
<p class="box" id="box3"> Box 3</p>
<p class="box" id="box4"> Box 4</p>
</body>
</html>
Output:-
People Also Read:- CSS Background Property
People Also Read:- CSS Selectors and Different types of Selectors
0 comments:
Post a Comment