它应该如何工作(六边形水平和垂直之间的空间):
但是当我添加一些元素(或调整浏览器窗口大小)时,flexbox会自动重新缩放所有六边形,但不会重新缩放边距。
我想创建完整的响应(自动调整大小)六边形区域。我可以使用传统的媒体查询来完成它,但我需要创建更灵活的页面。
我的代码:https://jsfiddle.net/t9jnvr05/2/
.row {
display: flex !important;
}
.mx-1 {
margin-right: .25rem !important;
margin-left: .25rem !important;
}
.mr-1 {
margin-right: .25rem !important;
}
.ml-1 {
margin-left: .25rem !important;
}
.mt--5 {
margin-top: -2.8rem !important;
}
.sh.v-hidden .sh-e .sh-c {
visibility:hidden !important;
}
.sh.sh-hexagon.sh-4 {
width: 180px;
height: 207px;
}
.sh.sh-hexagon.sh-2 {
width: 90px;
height: 103.5px;
}
.sh.sh-hexagon {
width: 40px;
height: 46px;
}
.sh {
position: relative;
visibility: hidden;
overflow: hidden;
}
.sh.sh-hexagon .sh-e {
transform: rotate(60deg);
}
.sh .sh-e, .sh .sh-e .sh-c {
position: relative;
visibility: hidden;
overflow: hidden;
width: 100%;
height: 100%;
min-height: 100%;
max-height: 100%;
min-width: 100%;
max-width: 100%;
}
.sh.sh-hexagon .sh-e .sh-c {
transform: rotate(-120deg);
background: red;
}
.sh .sh-e .sh-c {
visibility: visible !important;
}
<h3>1:</h3>
<div class="row">
<div class="sh sh-hexagon sh-4 mx-1"><div class="sh-e"><div class="sh-c"></div></div></div>
<div class="sh sh-hexagon sh-4 mx-1"><div class="sh-e"><div class="sh-c"></div></div></div>
</div>
<div class="row">
<div class="sh sh-hexagon sh-2 mr-1 v-hidden"><div class="sh-e"><div class="sh-c"></div></div></div>
<div class="sh sh-hexagon sh-4 mx-1 mt--5"><div class="sh-e"><div class="sh-c"></div></div></div>
<div class="sh sh-hexagon sh-2 ml-1 v-hidden"><div class="sh-e"><div class="sh-c"></div></div></div>
</div>
<h3>2:</h3>
<div class="row">
<div class="sh sh-hexagon sh-4 mx-1"><div class="sh-e"><div class="sh-c"></div></div></div>
<div class="sh sh-hexagon sh-4 mx-1"><div class="sh-e"><div class="sh-c"></div></div></div>
<div class="sh sh-hexagon sh-4 mx-1"><div class="sh-e"><div class="sh-c"></div></div></div>
<div class="sh sh-hexagon sh-4 mx-1"><div class="sh-e"><div class="sh-c"></div></div></div>
<div class="sh sh-hexagon sh-4 mx-1"><div class="sh-e"><div class="sh-c"></div></div></div>
<div class="sh sh-hexagon sh-4 mx-1"><div class="sh-e"><div class="sh-c"></div></div></div>
<div class="sh sh-hexagon sh-4 mx-1"><div class="sh-e"><div class="sh-c"></div></div></div>
<div class="sh sh-hexagon sh-4 mx-1"><div class="sh-e"><div class="sh-c"></div></div></div>
<div class="sh sh-hexagon sh-4 mx-1"><div class="sh-e"><div class="sh-c"></div></div></div>
<div class="sh sh-hexagon sh-4 mx-1"><div class="sh-e"><div class="sh-c"></div></div></div>
<div class="sh sh-hexagon sh-4 mx-1"><div class="sh-e"><div class="sh-c"></div></div></div>
<div class="sh sh-hexagon sh-4 mx-1"><div class="sh-e"><div class="sh-c"></div></div></div>
</div>
<div class="row">
<div class="sh sh-hexagon sh-2 mr-1 v-hidden"><div class="sh-e"><div class="sh-c"></div></div></div>
<div class="sh sh-hexagon sh-4 mx-1 mt--5"><div class="sh-e"><div class="sh-c"></div></div></div>
<div class="sh sh-hexagon sh-4 mx-1 mt--5"><div class="sh-e"><div class="sh-c"></div></div></div>
<div class="sh sh-hexagon sh-4 mx-1 mt--5"><div class="sh-e"><div class="sh-c"></div></div></div>
<div class="sh sh-hexagon sh-4 mx-1 mt--5"><div class="sh-e"><div class="sh-c"></div></div></div>
<div class="sh sh-hexagon sh-4 mx-1 mt--5"><div class="sh-e"><div class="sh-c"></div></div></div>
<div class="sh sh-hexagon sh-4 mx-1 mt--5"><div class="sh-e"><div class="sh-c"></div></div></div>
<div class="sh sh-hexagon sh-4 mx-1 mt--5"><div class="sh-e"><div class="sh-c"></div></div></div>
<div class="sh sh-hexagon sh-4 mx-1 mt--5"><div class="sh-e"><div class="sh-c"></div></div></div>
<div class="sh sh-hexagon sh-4 mx-1 mt--5"><div class="sh-e"><div class="sh-c"></div></div></div>
<div class="sh sh-hexagon sh-4 mx-1 mt--5"><div class="sh-e"><div class="sh-c"></div></div></div>
<div class="sh sh-hexagon sh-4 mx-1 mt--5"><div class="sh-e"><div class="sh-c"></div></div></div>
<div class="sh sh-hexagon sh-2 ml-1 v-hidden"><div class="sh-e"><div class="sh-c"></div></div></div>
</div>