Many friends found that the box model is a square by default when learning the front-end. How to turn the box into the desired model? First, let's take a look at the default situation---- <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=, initial-scale=1.0"> <style> .box{ width: 100px; height: 100px; background-color: rgb(116, 51, 51); box-shadow:0 10px 10px red; text-align: center; position:absolute; margin:0 auto; left:0; right:0; bottom:0; top:0; } </style> <title>Document</title> </head> <body> <div class="box"> </div> </body> </html> The default setting is a square, which may not look good to you. Let’s try a round one! <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style> .box{ width: 100px; height: 100px; border-radius: 50%; background-color: rgb(28, 99, 60); border: 5px solid rgb(55, 0, 255); position: absolute; margin: 0 auto; left: 0; right: 0; bottom: 0; top: 0; } </style> <title>Round</title> </head> <body> <div class="box"> </div> </body> </html> Look how round we are! Let’s take a look at the semicircular one! <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style> .box{ width: 100px; height: 50px; background-color: rgb(175, 42, 216); border: 3px solid rgb(26, 236, 26); border-top-right-radius: 50px; border-top-left-radius: 50px; position:absolute; margin: 0 auto; left: 0; right: 0; bottom: 0; top: 0; } </style> <title>semicircle</title> </head> <body> <div class="box"> </div> </body> </html> Let’s try other shapes! <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style> .box{ width: 100px; height: 100px; background-color: rgb(82, 84, 223); border-radius: 20px 15px 20px 10px; position: absolute; margin: 0 auto; left: 0; bottom: 0; right: 0; top: 0; } </style> <title>demo</title> </head> <body> <div class="box"> </div> </body> </html> Knowledge point analysis:
I hope this article has taught you how to use the border-radius property! This concludes this article on the simple introduction to the HTML+CSS box model case (circle, semicircle, etc.) "border-radius". For more relevant HTML+CSS box model content, please search 123WORDPRESS.COM's previous articles or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future! |
<<: How to fix some content in a fixed position when scrolling HTML page
>>: HTML realizes hotel screening function through form
Table of contents Preface Code Implementation Ide...
Since Zabbix version 3.0, it has supported encryp...
This article mainly introduces why v-if and v-for...
This article shares the specific code of js to ac...
Set the width of the body to the width of the wind...
In the MySQL database, null is a common situation...
Find the problem When retrieving the top SQL stat...
Table of contents What is an agent Basic knowledg...
Table of contents 1. VueRouter 1. Description 2. ...
Problem description: The following error message ...
Closures are one of the traditional features of p...
Alignment issues like type="radio" and t...
Mongodb has a db.serverStatus() command, which ca...
Table of contents 1. Mutex 1. Initialization of m...
I will not introduce what CUDA is, but will direc...