0
我想建立一个表,其中包含td
其中width
设置百分比和溢出水平滚动条。表 - 宽度百分比与溢出不工作
不幸的是,我没有设法做到这一点。
http://jsfiddle.net/ne45s2wf/1/
HTML
<div class="container">
<table>
<tbody>
<tr>
<td>cell 1
</td>
<td>cell 2
</td>
<td class="too-long">cell 3 loooooooooooooooooooooooooooooooooooooooooooong
</td>
</tr>
</tbody>
</table>
</div>
CSS
.container {
position: relative;
max-width: 500px;
background-color: red;
}
table {
width: 100%;
}
td.too-long {
background-color: darkgreen;
display: inline-block;
width: 20%;
overflow-x: scroll;
}
我想知道的第一件事是什么
td
-width相对百分比?是否有可能将其设置为相对于table
?我会设置
td
与overflow hidden
的最大宽度百分比。虽然这适用于td
,但当其宽度设置为百分比时,父容器不会将其宽度与td
孩子对齐。父母的宽度就好像孩子没有设置宽度一样。此外,该表现在不再“响应”了。
表格宽度很复杂。请参阅[自动表格]的规范(http://www.w3.org/TR/CSS21/tables.html#auto-table-layout)和[固定的](http://www.w3.org/TR/)。 CSS21/tables.html#fixed-table-layout) – Oriol
你需要更清楚。我们甚至不知道你想要什么 – RafaelTSCS