CSS3六角形程式碼

admin發表於2018-07-18

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

程式碼例項如下:

[HTML] 純文字檢視 複製程式碼執行程式碼
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>螞蟻部落</title>
<style type="text/css">
#six {
  width: 0;
  height: 0;
  border-left: 60px solid transparent;
  border-right: 60px solid transparent;
  border-bottom: 120px solid red;
  position: relative;
}
#six:after {
  content: "";
  width: 0;
  height: 0;
  border-left: 60px solid transparent;
  border-right: 60px solid transparent;
  border-top: 120px solid red;
  position: absolute;
  top: 40px;
  left: -60px;
}
.six {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
}
</style>
</head>
<body>
  <div class="six">
    <div id="six"></div>
  </div>
</body>
</html>

相關文章