【发布时间】:2021-10-08 18:24:53
【问题描述】:
我创建了一个如下所示的表:
由于某种原因,我无法将每行内的数字与标题居中。
我的 HTML 如下(我使用 Flask,所以这就是 for 循环的原因):
<div class="calculation_grid">
<ul class="responsive-table">
<li class="table-header">
{% for cell in headings %}
<div class="col"> {{ cell }}</div>
{% endfor %}
</li>
{% for row in data %}
<li class="table-row">
{% for cell in row %}
<div class="col"> {{ cell }}</div>
{% endfor %}
</li>
{% endfor %}
</ul>
</div>
还有我的 CSS:
ul {
padding: 0;
}
.responsive-table {
width: 100%;
table-layout : fixed;
}
.responsive-table li {
border-radius: 8px;
display: flex;
justify-content: space-between;
margin-bottom: 4px;
padding: 10px 30px;
overflow: hidden;
}
.responsive-table .table-header {
background-color: rgba(0, 0, 0, 0.2);
border: 1px solid rgba(255, 254, 5, 0.4);
color: white;
font-size: 1.5rem;
font-weight: bold;
letter-spacing: 0.03em;
text-transform: uppercase;
}
.responsive-table .table-row {
background: rgba(0, 0, 0, 0.9);
border: 1px solid rgba(255, 254, 5, 0.4);
box-shadow: 0px 0px 0px 0px rgba(0, 0, 0, 0.2);
color: white;
}
.responsive-table .table-row .col {
text-align: center;
}
@media all and (max-width: 100%) {
.responsive-table .table-header {
display: none;
}
.responsive-table li {
display: block;
}
.responsive-table .col {
flex-basis: 100%;
display: flex;
padding: 10px 0;
}
}
知道为什么它不会居中吗?
谢谢
【问题讨论】:
标签: css css-tables