HTML 表格列宽:固定宽度和可变宽度的结合
我制作了一个这样的表格:
<table style="width:1000px;">
<tr>
<td>aaa</td>
<td id="space"></td>
<td class="fixed-width">bbb</td>
<td class="fixed-width">ccc</td>
</tr>
</table>
如何使用 CSS 使 b 和 c 列具有固定宽度,a 列仅占用所需的空间,并且 space 列扩展以填充其余部分桌子?
I've made a table as such:
<table style="width:1000px;">
<tr>
<td>aaa</td>
<td id="space"></td>
<td class="fixed-width">bbb</td>
<td class="fixed-width">ccc</td>
</tr>
</table>
How would I do the CSS so that the b and c columns have a fixed width, the a column only takes as much space as needed, and the space column to expand to fill the rest of the table?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不是 CSS 专家,但没有办法做到这一点似乎不太正确。这似乎适用于 Firefox 和 IE7。我没有检查过其他浏览器。
第一个收缩贴合的设置(使用 CSS)为 0 宽度,因此它会缩小以适合内容。
第二个空格 设置(使用 CSS)的宽度大于表格适合的宽度。
最后两个固定宽度 的宽度不在 上。相反,它设置在 上。风格。这会强制列宽。
I'm no CSS guru, but it just didn't seem right that there'd be no way to do this. This appears to work in Firefox and IE7. I have not checked other browsers.
The first shrink-to-fit <col> is set (using CSS) to 0 width, so it shrinks to fit the content.
The second space <col> is set (using CSS) to a width larger than will fit in the table.
The width of the last two fixed-width <col>s is not on the <col>. Instead, it's set on the <td> style. This forces the column width.