我有th
个text-overflow: ellipsis; overflow: hidden; white-space: nowrap;
元素的标记。
此外,td
和th
设置为display: block
。
当我在width: 130px
上放置th
之类的内容时,文字会显示省略号,否则不会。
我不知道还有什么可以放在代码上,所以我会发布到目前为止的内容:
table {
display: flex;
overflow: hidden;
}
thead {
display: flex;
flex-shrink: 0;
width: 30%;
}
tbody {
display: flex;
position: relative;
width: 70%;
overflow-x: auto;
}
tr {
display: flex;
flex-direction: column;
min-width: 100%;
flex-shrink: 0;
}
td,
th {
display: block;
font-size: 13pt;
border: 1px solid black;
}
td {
border-left: 0;
}
th {
background-color: DarkSlateBlue;
font-weight: bold;
color: white;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
th:not(:last-child),
td:not(:last-child) {
border-bottom: 0;
}

<table>
<thead>
<tr id="trParticipantes">
<th> </th>
<th>Crispy Bacooooooooooooooooooooon</th>
<th>Marco</th>
<th>Filipe</th>
</tr>
</thead>
<tbody id="tbodyTempos">
<tr>
<td>Fase 1</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
</tr>
<tr>
<td>Fase 2</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
</tr>
<tr>
<td>Fase 3</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
</tr>
<tr>
<td>Fase 4</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
</tr>
<tr>
<td>Fase 5</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
</tr>
<tr>
<td>Fase 6</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
</tr>
<tr>
<td>Fase 7</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
</tr>
<tr>
<td>Fase 8</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
</tr>
<tr>
<td>Fase 9</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
</tr>
<tr>
<td>Fase 10</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
</tr>
<tr>
<td>Fase 11</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
</tr>
<tr>
<td>Fase 12</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
</tr>
<tr>
<td>Fase 13</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
</tr>
<tr>
<td>Fase 14</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
</tr>
<tr>
<td>Fase 15</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
</tr>
<tr>
<td>Fase 16</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
</tr>
<tr>
<td>Fase 17</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
</tr>
<tr>
<td>Fase 18</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
</tr>
<tr>
<td>Fase 19</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
</tr>
<tr>
<td>Fase 20</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
<td>
<input class="tempo" min="0" step=".1" type="number">
</td>
</tr>
</tbody>
</table>
&#13;
答案 0 :(得分:4)
tr上的'flex-shrink'属性需要设置为1,否则它只是从表中流出到下一个。默认值为1,告诉显示器缩小x框中其他项的值,因为只有一个项目将填充框。