css3繪製心形圖案程式碼例項

admin發表於2017-02-21

本章節分享一段程式碼例項,它實現了使用css3繪製心形圖案效果。

程式碼例項如下:

[HTML] 純文字檢視 複製程式碼
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>螞蟻部落</title>
<style type="text/css">
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html {
  font-size: 62.5%;
}
body {
  font-family: "mircoft yahei";
  font-size: 14px;
  font-size: 1.4rem;
  line-height: 1;
}
.heart {
  position: relative;
  width: 200px;
  height: 200px;
  background-color: #d31145;
  margin: 100px auto;
  transform: rotate(45deg);
  -webkit-transform: rotate(45deg);
  -o-transform: rotate(45deg);
  -ms-transform: rotate(45deg);
}
.heart:before, .heart:after {
  position: absolute;
  content: '';
  width: 200px;
  height: 200px;
  display: block;
  border-radius: 50%;
  background-color: #d31145;
}
.heart:before {
  left: -100px;
  bottom: 0;
}
.heart:after {
  top: -100px;
  right: 0;
}
</style>
</head>
<body>
<div class="heart"></div>
</body>
</html>

相關文章