css五角星程式碼例項

admin發表於2017-04-14

分享一段程式碼例項,它實現了五角星效果。

程式碼例項如下:

[HTML] 純文字檢視 複製程式碼
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>螞蟻部落</title>
<style type="text/css">
div {
  float: left;
  margin: 50px;
}
/*五角星*/
.star {
  position: relative;
  display: block;
  top: 15px;
  border-right: 100px solid transparent;
  border-bottom: 70px solid cadetblue;
  border-left: 100px solid transparent;
  -moz-transform: rotate(35deg);
  -webkit-transform: rotate(35deg);
  -ms-transform: rotate(35deg);
}
.star:before {
  position: absolute;
  display: block;
  top: -45px;
  left: -62px;
  border-bottom: 80px solid cadetblue;
  border-left: 30px solid transparent;
  border-right: 30px solid transparent;
  content: '';
  -webkit-transform: rotate(-35deg);
  -moz-transform: rotate(-35deg);
  -ms-transform: rotate(-35deg);
  -o-transform: rotate(-35deg);
}
.star:after {
  content: '';
  position: absolute;
  display: block;
  top: 3px;
  left: -105px;
  color: #fc2e5a;
  border-right: 100px solid transparent;
  border-bottom: 70px solid cadetblue;
  border-left: 100px solid transparent;
  -webkit-transform: rotate(-70deg);
  -moz-transform: rotate(-70deg);
  -ms-transform: rotate(-70deg);
  -o-transform: rotate(-70deg);
}
</style>
</head>
<body>
  <div class="star"></div>
</body>
</html>

相關文章