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