How to set ellipse in css

WBOY
Release: 2021-11-15 10:05:49
Original
12194 people have browsed it

How to set ellipse in css: 1. Add "{width: width value; height: height value;}" style to the element and set the element to a rectangle; 2. Add "{border-radius" to the rectangular element :100%;}" and set the rounded corner style to an ellipse.

How to set ellipse in css

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

How to set ellipse in css

1. We can first create a rectangle for the div element, and then use the border-radius attribute class of css Set the rounded corners of the rectangle to get the ellipse. The code is as follows:

Create a rectangle first

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>css制作椭圆</title>
<style>
.ellipse{
width: 200px;
height: 100px;
background-color: red;
}
</style>
</head>
<body>
<div class="ellipse"></div>
</body>
</html>
Copy after login

Output result:

How to set ellipse in css

2. Then set the rounded corners through the border-radius attribute. Add: border-radius:100%; to the ellipse attribute to set the ellipse.

In order to be compatible with various browsers, we also need to add

-o-border-radius:100%;
-ms-border-radius:100%;
-moz-border-radius:100%;
-webkit-border-radius:100%;
Copy after login
here

How to set ellipse in css

The code is as follows:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>css制作椭圆</title>
<style>
.ellipse{
width: 200px;
height: 100px;
background-color: red;
border-radius:100%;
-o-border-radius:100%;
-ms-border-radius:100%;
-moz-border-radius:100%;
-webkit-border-radius:100%;
}
</style>
</head>
<body>
<div class="ellipse"></div>
</body>
</html>
Copy after login

Output result:

How to set ellipse in css

For more programming related knowledge, please visit: Programming Video! !

The above is the detailed content of How to set ellipse 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