用HTML5做一个爱心图案代码
时间: 2024-05-11 14:12:41 浏览: 22
好的,以下是一个用HTML5和CSS3实现的爱心图案的代码:
```
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Love Heart</title>
<style>
.heart {
position: relative;
width: 100px;
height: 90px;
transform: rotate(-45deg);
margin: 50px auto;
}
.heart:before,
.heart:after {
content: "";
position: absolute;
background-color: #fc2d63;
border-radius: 50px 50px 0 0;
}
.heart:before {
width: 50px;
height: 50px;
top: -25px;
left: 0;
}
.heart:after {
width: 50px;
height: 50px;
top: -25px;
right: 0;
}
.heart .heart-center {
position: absolute;
top: -15px;
left: 25px;
width: 50px;
height: 50px;
border-radius: 50%;
background-color: #fc2d63;
}
</style>
</head>
<body>
<div class="heart">
<div class="heart-center"></div>
</div>
</body>
</html>
```
这段代码使用了CSS3的transform属性来旋转爱心,使用了伪元素before和after来实现左右两边的半圆形,使用了div元素来实现中心的圆形。你可以将这段代码保存为一个HTML文件并在浏览器中打开来查看效果。
相关推荐
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)