小编Pro*_*ist的帖子

固定宽度表中流体列的最小宽度

我正在尝试创建一个表格,其中流体列具有最小宽度。所有其他列都有固定的宽度,并且不应变宽或变薄。

我可以让流体柱正确地增长和收缩,以便它占据容器中的剩余空间,将最大宽度设置为 900px,但是我无法让它采用最小宽度。

这意味着当窗户和容器被压扁时,流体柱会被覆盖,而不是像此时的固定柱一样。

对 th 和/或 td 应用最小宽度不会执行任何操作。对流体 td 内的 div 应用 min-wdith 确实意味着文本具有最小宽度,但是它不会阻止列缩小到小于此最小值,因此文本位于下一列文本的下方。

有任何想法吗?

HTML:

<div class="container">
<table>
    <thead>
        <tr>
            <th class="fixed">fixed</th>
            <th class="fixed">fixed</th>
            <th class="fixed">fixed</th>
            <th class="fluid">fluid</th>
            <th class="fixed">fixed</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>fixed</td>
            <td>fixed</td>
            <td>fixed</td>
            <td class="fluid"><div align="left">Some text here which gets truncated, however should have min width</div></td>
            <td>fixed</td>
        </tr>  
    </tbody>            
</table>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS:

.container {
    max-width: 900px;
}

table {
    table-layout: fixed;
    width: 100%;
    border: 1px solid #333;
    border-collapse: separate;
    border-spacing: 0;
}

th.fixed { …
Run Code Online (Sandbox Code Playgroud)

html css html-table fixed-width

5
推荐指数
1
解决办法
7811
查看次数

标签 统计

css ×1

fixed-width ×1

html ×1

html-table ×1