【发布时间】:2022-01-12 11:02:29
【问题描述】:
我正在表格中创建一个可编辑的单元格,但是尽管在其中输入overflow: auto css 只会使它以一种非常尴尬的方式展开。
如何使其保持初始单元格大小,并根据需要显示滚动条?最好不要设置宽度/高度的像素值,因此整个表格将在不同分辨率或放大和缩小(控制+鼠标滚轮)之间保持在屏幕上。
html {
box-sizing: border-box;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
html,
.table {
width: 100%;
height: 100%;
border: 1px solid #000;
}
cell {
overflow: auto;
}
<table class="table">
<tr>
<th>Person 1</th>
<th>Person 2</th>
<th>Person 3</th>
</tr>
<tr>
<td>Emil</td>
<td>Tobias</td>
<td>Linus</td>
</tr>
<tr>
<td>
<div contenteditable="true" class="cell">Editable cell</div>
</td>
<td>14</td>
<td>10</td>
</tr>
</table>
【问题讨论】:
标签: html css html-table contenteditable