HTML CSS 表格布局

标签 html css dynamic width css-tables

我在创建合适的表格布局时遇到问题。

我需要表格有一个特定的宽度,有 3 列(目前没有问题)。 问题是我需要第二列只需要其内容的宽度,不能更大,并且该列必须动态适应该内容。

另外两个应该占据表格的剩余宽度。

例子:

---------------------------------------------------------------------------------
|                             |Here is the main text|                           |
---------------------------------------------------------------------------------

最佳答案

DEMO FIDDLE

HTML

<table>
    <tr>
        <td>Row 1 Col 1</td>
        <td>Row 1 Col 2</td>
        <td>Row 1 Col 3</td>
    </tr>
</table>

CSS

table {
    width:100%;
}
td {
    border:1px solid grey;
}
td:nth-child(2) {
    width:1px;
    white-space:nowrap;
}

关于HTML CSS 表格布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20684134/

相关文章:

复制到 C 中动态分配的数组

C# 动态 Linq : Implement "Like" in The Where Clause

html - 在跨度上添加一个字符

html - 图像之间不需要的间距

css3pie 从 ie7,8 中的圆形元素泄漏图像

html - Bootstrap Z-index 图像不工作

c++ - 在 C++ 中初始化和使用动态数组

javascript - 如何在 .html 模板 Angular 中的 div 上定义多种样式

html - 如何在我的 web.config 中包含我的 CSS 文件的路径?

html - 有没有办法在 html 电子邮件中的 "a:hover"上的 href 链接上设置内联样式?