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
1. Go to the official website: D:\mysql-5.7.21-wi...
1. Disk partition: 2. fdisk partition If the disk...
Table of contents 1. Problem Description 2. Probl...
This article shares the specific code for JavaScr...
Table of contents 1. Download 2. Installation and...
Table of contents fold (reduce) Using for...of Us...
Today we will introduce several ways to use CSS t...
When I was printing for a client recently, he aske...
Table of contents Preface Dynamic SQL 1. Take a l...
Table of contents process Demo Mini Program Backe...
Table of contents Preface Reference Comparison Ma...
1. Preparation before installation Check the data...
1. Parent components can use props to pass data t...
To merge the following two files, merge them toge...
Table of contents 1. User created script 2. Word ...