知识点
- 伪元素::before、::after的使用
- 边框的知识,border-radius
- 定位 子绝父相
源代码如下
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
.heart{
width: 300px;
height: 300px;
background-color: pink;
margin: 100px auto;
position: relative;
}
.heart::before,.heart::after{
position: absolute;
display: block;
content:".";
width: 150px;
height: 250px;
background-color: red;
border-top-left-radius: 50% 75px;
border-top-right-radius: 50% 75px;
left: 41px;
top: 0px;
transform: rotate(-45deg);
}
.heart::after{
transform: rotate(45deg);
left: 112px;
}
</style>
</head>
<body>
<div class="heart">
</div>
</body>
</html>
效果图如下