Nowadays, you can see rounded corner in image, buttons, etc.. in website or in application, Like profile picture of WhatsApp and Instagram. Round corner or whole round effects are done by border-radius property. Rounded corner shape gives different and unique look to HTML elements. This also affects your website looks.
This post shows you different shapes design using “border-radius” property.
border-radius property
border-radius property is CSS property which allows you to make HTML elements corner in round shape. You can apply property value in pixel (px) or in percentage (%).
border-radius property is shorthand property of following four property.
• border-top-left-radius property
• border-top-right-radius property
• border-bottom-right-radius property
• border-bottom-left-radius property
First we discuss about above four properties and after that discuss how border-radius property apply these four value to HTML elements.
border-top-left-radius property
border-top-right-radius property
border-bottom-right-radius property
border-bottom-left-radius property
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | <!DOCTYPE html> <html> <head> <title>border-radius</title> <style> .top-left,.top-right,.bottom-right,.bottom-left{ margin:50px; height:300px; width:500px; background-color:slateblue; } .top-left{border-top-left-radius:50px;} .top-right{border-top-right-radius:50px;} .bottom-right{border-bottom-right-radius:50px;} .bottom-left{border-bottom-left-radius:50px;} h2{ padding:20%; text-align:center; } </style> </head> <body> <div class="top-left"> <h2>border-top-left-radius</h2> </div> <div class="top-right"> <h2>border-top-right-radius</h2> </div> <div class="bottom-right"> <h2>border-bottom-right-radius</h2> </div> <div class="bottom-left"> <h2>border-bottom-left-radius</h2> </div> </body> </html> |
Examples of border-radius property
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | <!DOCTYPE html> <html> <head> <title>border-radius</title> <style> .example1{ margin:50px; height:300px; width:500px; background-color:slateblue; border-radius:30px;} h2{ padding:20%; text-align:center; } </style> </head> <body> <div class="example1"> <h2>border-radius of all corner 30px</h2> </body> </html> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | <!DOCTYPE html> <html> <head> <title>border-radius</title> <style> .example2{ margin:50px; height:300px; width:500px; background-color:slateblue; border-radius:30px 65px;} h2{ padding:20%; text-align:center; } </style> </head> <body> <div class="example2"> <h2>border-radius:30px 65px</h2> </body> </html> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | <!DOCTYPE html> <html> <head> <title>border-radius</title> <style> .example3{ margin:50px; height:300px; width:500px; background-color:slateblue; border-radius:30px 55px 20px;} h2{ padding:20%; text-align:center; } </style> </head> <body> <div class="example3"> <h2>border-radius:30px 55px 20px</h2> </body> </html> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | <!DOCTYPE html> <html> <head> <title>border-radius</title> <style> .example4{ margin:50px; height:300px; width:500px; background-color:slateblue; border-radius:30px 55px 20px 75px;} h2{ padding:20%; text-align:center; } </style> </head> <body> <div class="example4"> <h2>border-radius:30px 55px 20px 75px</h2> </body> </html> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | <!DOCTYPE html> <html> <head> <title>border-radius</title> <style> .example5{ height:300px; width:300px; background-color:red; border-radius:20px/50px; } h2{ padding:20%; text-align:center; } </style> </head> <body> <div class="example5"> <h2>border-radius:20px/50px</h2> </body> </html> |
1 2 3 4 5 6 | .example5{ height:300px; width:300px; background-color:red; border-radius:50px/20px; } |
Now, how to make whole round shape of an Elements?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | <!DOCTYPE html> <html> <head> <title>border-radius</title> <style> .round{ height:400px; width:400px; background-color:lime; border-radius:200px; } </style> </head> <body> <div class="round"></div> </body> </html> |
1 2 3 4 5 6 | .round{ height:300px; width:400px; background-color:lime; border-radius:50%; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | <html> <head> <title>div tag border radius</title> <style> .main{ position:absolute; height:500px; width:500px; margin:200px; background-color:skyblue; } #bdrrd1{ position:absolute; height:300px; width:300px; margin:100px; border:1px solid black; border-radius:150px; background-color:#ffccee; } #bdrrd2{ position:absolute; height:200px; width:200px; margin-left:10px; margin-top:10px; border:1px solid black; border-radius:20px; background-color:#ffccee; } #bdrrd3{ position:absolute; height:200px; width:200px; margin:300px; border:1px solid black; border-radius:0px 100px 0px 0px; background-color:#ffccee; } #bdrrd4{ position:absolute; height:200px; width:200px; margin-left:300px; border:1px solid black; border-radius:0px 100px 0px 100px; background-color:#ffccee; } #bdrrd5{ position:absolute; height:200px; width:200px; margin-top:300px; border:1px solid black; border-radius:0px 0px 100px 100px; background-color:#ffccee; } </style> </head> <body> <div class="main"> <div id="bdrrd1"></div> <div id="bdrrd2"></div> <div id="bdrrd3"></div> <div id="bdrrd4"></div> <div id="bdrrd5"></div> </div> </body> </html> |
0 Comments