May 29, 2021 Article blog
The other day, the W3Cschool editor-in-chief taught everyone to draw basic graphics using CSS. S o now we're going to start a new chapter and learn some special graphics. So this article, small editor teaches you how to draw a semicircle with CSS.
Let's take a look at the final effect:
source:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>W3Cschool-编程狮</title>
<style type="text/css">
#semi-circle{
width: 200px;
height: 100px;
background-color: red;
border-radius:100px 100px 0 0;/* 左上、右上、右下、左下 */
}
</style>
</head>
<body>
<div id="semi-circle"></div>
</body>
</html>
The example above is to draw an upper half circle, and if you want to draw a semicircle in another direction, you only need to modify the code of
border-radius