通过transform: skewX(100deg),使元素倾斜,达到菱形的试图效果
效果如图:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>yuanzhu</title>
<style>
.container{
margin: 100px auto;
width: 200px;
display: flex;
}
div[class^="square"]{
width: 50px;
height: 150px;
background: rgb(213, 241, 142);
transform: skewX(-25deg);
margin-right: 10px;
}
</style>
</head>
<body>
<div class="container">
<div class="square1"></div>
<div class="square2"></div>
<div class="square3"></div>
</div>
</body>
</html>