用H5写一个蜂巢六边形网格
时间: 2024-05-29 12:11:14 浏览: 144
新版H5跳一跳3D在线小游戏无错完整版_h5_跳一跳_
5星 · 资源好评率100%
<!DOCTYPE html>
<html>
<head>
<title>蜂巢六边形网格</title>
<style>
body {
margin: 0;
padding: 0;
background-color: #f2f2f2;
}
.hexagon {
position: relative;
width: 100px;
height: 115px;
background-color: #fff;
margin: 15px 0 0 15px;
float: left;
-webkit-clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
border: 2px solid #fff;
}
.hexagon:before,
.hexagon:after {
content: "";
position: absolute;
top: -25px;
left: 0;
width: 0;
height: 0;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-bottom: 25px solid #fff;
}
.hexagon:after {
top: 115px;
border-top: 25px solid #fff;
border-bottom: none;
}
.clearfix:before,
.clearfix:after {
content: "";
display: table;
}
.clearfix:after {
clear: both;
}
</style>
</head>
<body>
<div class="clearfix">
<div class="hexagon"></div>
<div class="hexagon"></div>
<div class="hexagon"></div>
<div class="hexagon"></div>
<div class="hexagon"></div>
<div class="hexagon"></div>
</div>
<div class="clearfix">
<div class="hexagon"></div>
<div class="hexagon"></div>
<div class="hexagon"></div>
<div class="hexagon"></div>
<div class="hexagon"></div>
<div class="hexagon"></div>
<div class="hexagon"></div>
</div>
<div class="clearfix">
<div class="hexagon"></div>
<div class="hexagon"></div>
<div class="hexagon"></div>
<div class="hexagon"></div>
<div class="hexagon"></div>
<div class="hexagon"></div>
</div>
<div class="clearfix">
<div class="hexagon"></div>
<div class="hexagon"></div>
<div class="hexagon"></div>
<div class="hexagon"></div>
<div class="hexagon"></div>
</div>
<div class="clearfix">
<div class="hexagon"></div>
<div class="hexagon"></div>
<div class="hexagon"></div>
<div class="hexagon"></div>
</div>
<div class="clearfix">
<div class="hexagon"></div>
<div class="hexagon"></div>
<div class="hexagon"></div>
</div>
<div class="clearfix">
<div class="hexagon"></div>
<div class="hexagon"></div>
</div>
</body>
</html>
阅读全文