【发布时间】:2021-06-03 04:20:07
【问题描述】:
我正在尝试制作一些响应方表格单元格。我知道这个问题的答案,但它们似乎都适用于 3x3 网格,我找不到 2x4 版本。我也不希望它必须滚动,它需要适合菜单。它应该始终是方形的,如果它不适合高度,请按比例缩小。我希望它水平和垂直居中。我该怎么做呢? 这是有问题的网站。 The Site。 您可以看到右侧的网格如何适合高度和宽度,但不是正方形。我该如何解决这个问题?
.menu{
background: #222222;
position: absolute;
top: 50%;
/*left: 50%;*/
}
.menu.right{
width: 25%;
height: 70%;
/*transform: translate(-50%, -50%);*/
top: 5%;
right: 0;
float: right;
/*display: grid;
grid-gap: 5px;
*/
/*grid-template-columns: auto auto;*/
/*grid-template-rows: auto auto auto auto;
grid-template-columns: repeat(2, 50%);
*/
/*grid-template: repeat(4, 1fr) / repeat(2, 1fr);
padding: 5px;*/
display: flex;
flex-direction: column;
}
#statwrap{
box-sizing: border-box;
display: flex;
width: 100%;
height: 100%;
flex-direction: row;
padding: 5px;
}
#stattab{
width: 100%;
height: 100%;
flex: 1;
border-spacing: 10px 10px;
}
#statbody{
}
.statcell{
background: #333333;
border-radius: 15px;
width: 50%;
}
<div class="menu right">
<!--
<div class="stat one"></div>
<div class="stat two"></div>
<div class="stat three"></div>
<div class="stat four"></div>
<div class="stat five"></div>
<div class="stat six"></div>
<div class="stat seven"></div>
<div class="stat eight"></div>
-->
<div id="statwrap">
<table id="stattab">
<tbody id="statbody">
<tr>
<td class="statcell"></td>
<td class="statcell"></td>
</tr>
<tr>
<td class="statcell"></td>
<td class="statcell"></td>
</tr>
<tr>
<td class="statcell"></td>
<td class="statcell"></td>
</tr>
<tr>
<td class="statcell"></td>
<td class="statcell"></td>
</tr>
</tbody>
</table>
</div>
</div>
谢谢。
【问题讨论】:
标签: html css html-table responsive