css六边形效果代码实例

快乐打工仔 分类:实例代码

分享一段代码实例,它实现了六边形效果。

代码如下:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.pipipi.net/" />
<title>前端教程网</title>
<style>
* {
  margin: 0;
  padding: 0;
}
/*css*/
.ant {
  position: relative;
  width: 200px;
  height: 120px;
  background-color: red;
  margin: 100px;
}
.ant:after {
  content: "";
  position: absolute;
  display: block;
  top: -160px;
  width: 0;
  height: 0;
  border: 100px solid transparent;
  border-bottom: 60px solid red;
}
.ant:before {
  content: "";
  position: absolute;
  display: block;
  bottom: -160px;
  width: 0;
  height: 0;
  border: 100px solid transparent;
  border-top: 60px solid red;
}
</style>
</head> 
<body> 
  <div class="ant"></div>
</body> 
</html>

css六边形效果代码实例,这样的场景在实际项目中还是用的比较多的,关于css六边形效果代码实例就介绍到这了。

css六边形效果代码实例属于前端实例代码,有关更多实例代码大家可以查看

回复

我来回复
  • 暂无回复内容