Home  >  Article  >  Web Front-end  >  How to make css pictures round

How to make css pictures round

青灯夜游
青灯夜游Original
2021-07-21 16:55:1610392browse

In CSS, you can use the border-radius attribute to make the image round. You only need to add the "border-radius: 50%;" style to the img element. The border-radius attribute can set a rounded border to an element. The radius of the rounded corners cannot exceed half the width/height.

How to make css pictures round

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

In CSS, you can use the border-radius attribute to make the image round.

Let’s take a closer look at the code example:

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<style type="text/css">
			img{
				border-radius: 50%;
			}
		</style>
	</head>
	<body>
		<img  src="img/1.jpg"    style="max-width:90%"  style="max-width:90%"/ alt="How to make css pictures round" >

	</body>
</html>

Rendering:

How to make css pictures round

Description :

border-radius attribute is used to set a rounded border for an element. You can specify a value of 1-4 to create (1~4) rounded corners for the border; the radius of the rounded corners cannot exceed the width. /Half the height.

Syntax:

border-radius: 1-4 length|%

Value:

  • length Defines the shape of the curve.​

  • % Use % to define the shape of the corners.​

Note: The order of the four values ​​​​for each radius is: upper left corner, upper right corner, lower right corner, lower left corner. If the lower left corner is omitted, the upper right corner is the same. If the lower right corner is omitted, the upper left corner is the same. If the upper right corner is omitted, the upper left corner is the same.

  • Four values: The first value is the upper left corner, the second value is the upper right corner, the third value is the lower right corner, and the fourth value is the lower left corner.

    border-radius: 15px 50px 30px 5px

    How to make css pictures round

  • ##Three values: first The first value is the upper left corner, the second value is the upper right corner and the lower left corner, and the third value is the lower right corner

    border-radius: 15px 50px 30px

    How to make css pictures round

  • Two values: the first value is the upper left corner and the lower right corner, the second value is the upper right corner and the lower left corner

    border- radius: 15px 50px

    How to make css pictures round

  • One value: The four rounded corners have the same value

    border-radius: 25px

    How to make css pictures round

(Learning video sharing:

css video tutorial

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

Statement:
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