效果:
代码:
<!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>爱心</title>
<style>
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
.heart{
position: relative;
margin: 100px auto;
width: 50px;
height: 50px;
background-color: red;
transform: rotate(45deg);
}
.heart::before{
position: absolute;
top: -50%;
content: "";
display: block;
width: 50px;
height: 50px;
background-color: red;
border-radius: 50%;
}
.heart::after{
position: absolute;
left: -50%;
content: "";
display: block;
width: 50px;
height: 50px;
background-color: red;
border-radius: 50%;
}
</style>
</head>
<body>
<div class="heart"></div>
</body>
</html>