Home > Web Front-end > Front-end Q&A > How to realize semicircle in css

How to realize semicircle in css

藏色散人
Release: 2021-05-27 11:40:35
Original
4148 people have browsed it

How to implement a semicircle in css: first create an HTML sample file; then enter a p tag in the body; then set the height to half of the width, and define the fillet radii of the upper left corner and upper right corner The height of the elements is consistent; finally, define the fillet radius of the lower right corner and the lower left corner as 0 to achieve the semicircle effect.

How to realize semicircle in css

The operating environment of this article: Windows7 system, HTML5&&CSS3 version, DELL G3 computer

How to realize a semicircle in css?

Semicircle

The semicircle is divided into: upper semicircle, lower semicircle, left semicircle, and right semicircle. We only need to learn to make semicircles in one direction, and other directions Semicircles can be easily realized, and the principles are the same.

If we want to make an upper semicircle, the implementation principle is: set the height to half the width, and define the fillet radius of the upper left corner and the upper right corner to be the same height of the element, and the lower right corner and the lower left corner are The corner radius is defined as 0.

while the corner radius of the lower right and lower left corners is defined as 0.

<!DOCTYPE html><html lang="en"><head>
    <meta charset="UTF-8">
    <title>半圆角</title>
    <style type="text/css">
        p{
            width: 100px;
            height: 50px;
            border:1px solid black;
            background-color: blue;
            border-radius: 100px 100px 0 0;
        }
    </style></head><body>
    <p></p></body></html>
Copy after login

Result:

Circle

Implementation method: Set the width and height to be the same, and then set the corner radius to half of the width and height

<!DOCTYPE html><html lang="en"><head>
    <meta charset="UTF-8">
    <title>圆</title>
    <style type="text/css">
        p{
            width: 100px;
            height: 100px;
            border:1px solid black;
            background-color: blue;
            border-radius: 50px;
        }
    </style></head><body>
    <p></p></body></html>
Copy after login

Result:

Recommended: "HTML Video Tutorial" "css Video Tutorial"

The above is the detailed content of How to realize semicircle in css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template