border-radius method to add rounded borders to elements

border-radius method to add 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).

div{

       height:50px;/*half of width*/
       width:100px;
     background:#9da;
       border-radius:50px 50px 0 0;/*The radius should be at least the value of height*/
       }

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:

div{
     height:100px;/*same as width setting*/
      width:100px;
      background:#9da;
      border-radius:50px;/*The four corner radius values ​​are all set to half of the width or height value*/
      }

Complete code

<!doctype html>
  <html>
  <head>
  <meta charset="utf-8">
  <title>border-radius</www.dztcsd.com/title>
  <style type="text/css">
  div.circle{
       height:100px;/*same as width setting*/
       width:100px;
       background:#9da;
       border-radius:50px;/*The four corner radius values ​​are all set to half of the width or height value*/
       }
   /*Task part*/
      div.semi-circle{
        height:100px;
       width:50px;
       background:#9da;
       border-radius:?;
       }

         </style>
  </head>
  <body>
  <div class="circle">
  </div>
  <br/>
  <!--Task section-->
  <div class="semi-circle">
  </div>

    </body>
  </html>

This is the end of this article about the border-radius method of adding rounded borders to elements. For more related border-radius rounded border content, please search 123WORDPRESS.COM’s previous articles or continue to browse the following related articles. I hope that everyone will support 123WORDPRESS.COM in the future!

<<:  A detailed introduction to the use of block comments in HTML

>>:  Detailed explanation of webpage screenshot function in Vue

Recommend

Ideas and codes for implementing waterfall flow layout in uniapp applet

1. Introduction Is it considered rehashing old st...

Introduction to JavaScript Number and Math Objects

Table of contents 1. Number in JavaScript 2. Math...

A brief introduction to Linux environment variable files

In the Linux system, environment variables can be...

How to set up a shared folder on a vmware16 virtual machine

1. Set up a shared folder on the virtual machine:...

Dynamic starry sky background implemented with CSS3

Result:Implementation Code html <link href=...

Solution to mysql ERROR 1045 (28000) problem

I encountered mysql ERROR 1045 and spent a long t...

Analysis of permissions required to run docker

Running Docker requires root privileges. To solve...

Vue.js implements the code of clicking the icon to zoom in and leaving

The previous article introduced how Vue can reali...

How to configure MySQL scheduled tasks (EVENT events) in detail

Table of contents 1. What is an event? 2. Enable ...

Sample code for implementing DIV suspension with pure CSS (fixed position)

The DIV floating effect (fixed position) is imple...

Pure CSS to achieve a single div regular polygon transformation

In the previous article, we introduced how to use...

Solution to Ubuntu not being able to connect to the Internet

Problem description: I used a desktop computer an...

Linux bash: ./xxx: Unable to execute binary file error

Today I sent a small tool for Ubuntu to a custome...

Summary of various implementation methods of mysql database backup

This article describes various ways to implement ...

Analyzing ab performance test results under Apache

I have always used Loadrunner to do performance t...