border-radius is a method for adding rounded borders to elements

border-radius is a method for adding rounded borders to elements

border-radius:10px; /* All corners are rounded with a radius of 10px*/

border-radius: 5px 4px 3px 2px; /* The four radius values ​​are the upper left corner, upper right corner, lower right corner and lower left corner, clockwise*/

Don’t think that border-radius values ​​can only be expressed in px units. You can also use percentages or ems, but the compatibility is not very good at the moment.

Solid upper semicircle:

Method: Set the height to half of the width, and only set the radius of the upper left and upper right corners to match the height of the element (it can be larger).

XML/HTML CodeCopy content to clipboard
  1. div{
  2.   
  3. height:50px;/*half of width*/
  4.   
  5. width:100px;
  6.   
  7. background:#9da;
  8.   
  9. border-radius:50px 50px 0 0;/*The radius should be at least the value of height*/
  10.   
  11. }

Filled circle:

Method: Set the width and height values ​​to be consistent (that is, a square), and set the four corner radius values ​​to half of their values.

The following code:

CSS CodeCopy content to clipboard
  1. div{
  2.   
  3.   height : 100px ; /*same as width setting*/   
  4.   
  5.   width : 100px ;
  6.   
  7.   background : #9da ;
  8.   
  9.   border -radius: 50px ; /*The four corner radius values ​​are all set to half of the width or height value*/   
  10.   
  11. }
XML/HTML CodeCopy content to clipboard
  1. <!doctype html >   
  2. < html >   
  3. < head >   
  4. < meta   charset = "utf-8" >   
  5. < title > border-radius </ www.dztcsd.com /title >   
  6. < style   type = "text/css" >   
  7. div.circle{
  8. height:100px;/*same as width setting*/
  9. width:100px;
  10. background:#9da;
  11. border-radius:50px;/*The four corner radius values ​​are all set to half of the width or height value*/
  12. }
  13. /*Task part*/
  14. div.semi-circle{
  15. height:100px;
  16. width:50px;
  17. background:#9da;
  18. border-radius:?;
  19. }
  20.       
  21. </ style >   
  22. </ head >   
  23. < body >   
  24. < div   class = "circle" >   
  25. </ div >   
  26. < br />   
  27. <!--Task section-->   
  28. < div   class = "semi-circle" >   
  29. </ div >   
  30.   
  31. </ body >   
  32. </ html >   

The above is all the content of the border-radius method for adding rounded borders to elements. I hope it will be helpful to everyone. Please support 123WORDPRESS.COM~

<<:  JavaScript to achieve balance digital scrolling effect

>>:  Detailed explanation of how to synchronize data from MySQL to Elasticsearch

Recommend

6 Uncommon HTML Tags

First: <abbr> or <acronym> These two s...

Introduction and examples of hidden fields in HTML

Basic syntax: <input type="hidden" na...

Summary of 10 amazing tricks of Element-UI

Table of contents el-scrollbar scroll bar el-uplo...

Detailed examples of Zabbix remote command execution

Table of contents one. environment two. Precautio...

Detailed installation process of Jenkins on Linux

Table of contents 1. Install JDK 2. Install Jenki...

How to deploy a simple c/c++ program using docker

1. First, create a hello-world.cpp file The progr...

Vue installation and use

Table of contents 1. Vue installation Method 1: C...

Write a formal blog using XHTML CSS

The full name of Blog should be Web log, which me...

MySQL MyISAM default storage engine implementation principle

By default, the MyISAM table will generate three ...

The difference between MySQL execute, executeUpdate and executeQuery

The differences among execute, executeUpdate, and...

Use elasticsearch to delete index data regularly

1. Sometimes we use ES Due to limited resources o...

JavaScript pie chart example

Drawing EffectsImplementation Code JavaScript var...