Home  >  Article  >  Web Front-end  >  How to achieve a rhombus effect that is not a right angle in css3

How to achieve a rhombus effect that is not a right angle in css3

WBOY
WBOYOriginal
2021-12-08 14:37:341683browse

In css, you can use the "clip-path" attribute to achieve a diamond-shaped effect that is not a right angle. This attribute can crop the display area of ​​the element. You only need to crop the display area of ​​the element into a diamond shape. The syntax is "clip -path:polygon(50% 0,100% 50%,50% 100%,0 50%);".

How to achieve a rhombus effect that is not a right angle in css3

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

How to achieve a rhombus effect that is not a right angle in css3

In css, you can use the clip-path attribute to create a displayable element using clipping. area. Parts within the area are displayed and parts outside the area are hidden.

Use this attribute to crop the element into a diamond shape. The example is as follows:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .imgClip{
clip-path: polygon(50% 0,100% 50%,50% 100%,0 50%);
}
    </style>
</head>
<body>
<img class="imgClip" src="1118.02.png" alt="">
</body>
</html>

Output result:

How to achieve a rhombus effect that is not a right angle in css3

(Learning video sharing: css video tutorial)

The above is the detailed content of How to achieve a rhombus effect that is not a right angle in css3. 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