我有一个 100% 宽度的 3 列表格。中心列的宽度必须为 600 像素。如何在用完剩余空间的同时让另外两个宽度相等?
<table style="width: 100%">
<tr>
<td>left</td>
<td style="width: 600px">center</td>
<td>right</td>
</tr>
</table>
目前,根据左栏或右栏的内容,它们总是不均匀的。我尝试过在左侧和右侧设置 50% 宽度以及其他数字和最小宽度试验。
请不要使用 jQuery/Javascript。
这个老问题的新答案。
- 给出中间的列
th
a max-width
and min-width
代替width
- 给左边和右边
th
a width
of 50%
.
- 不要给
table
a width
at all.
我已经修复了这个示例的中间列width
at 300px
.
jsBin 示例!
CSS
table {
border-collapse: collapse;
}
th, td {
border: solid 1px #CCC;
padding: 10px;
}
.fixed {
max-width: 300px;
min-width: 300px;
}
.fluid {
width: 50%;
}
HTML
<table>
<thead>
<tr>
<th class="fluid">First Column</th>
<th class="fixed">Fixed Column</th>
<th class="fluid">Third Column</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)