我正在用php中的foreach循环创建一个表,以创建列。是否可以使列的宽度均匀,例如3列->列宽33%,4列-> 25%,5列-> 20%,依此类推?现在感觉像列的宽度是随机的。
一些需要的代码:
PHP / HTML
echo '<tr>';
$permgroups = $perms->getPermissiongroups();
foreach ($permgroups as $group) {
if ($group != "user_ID") {
echo '<th>'.$group.'</th>';
}
}
echo '</tr>';
CSS
.structure_content table {
margin-top: 10px;
margin-bottom: 10px;
line-height: 30px;
background: #BDBDBD;
width: 100%;
float: right;
border-top: 1px solid #CEDADC;
border-bottom: 1px solid #CEDADC;
}
.structure_content th {
font-size: 20px;
}
答案 0 :(得分:0)
只需给您的桌子 time status
100 0
90 1
....
table-layout:fixed
table {
table-layout:fixed;
width:100%;
margin-bottom: 1em;
}
td {
padding:.5em;
border:1px solid red;
}