[英]How to make INPUT element fill the entire table TD cell
With this example table: 使用此示例表:
<table>
<tbody>
<tr>
<td>
<input value = "this is the text">
</td>
</tr>
</tbody>
</table>
I have the <input>
element populating the table's <td>
cell. 我有
<input>
元素填充表的<td>
单元格。 By default it (the <input>
element) does not take all the space available by its <td>
cell. 默认情况下,它(
<input>
元素)不会占用其<td>
单元格的所有可用空间。 How to make sure that the <input>
element always fills the space from edge to edge? 如何确保
<input>
元素始终填充边缘之间的空间?
Try this: 尝试这个:
table { width: 100%; border: 1px solid #ccc; } table td input { // display: block; width: 100%; }
<table> <tbody> <tr> <td> <input value = "this is the text"> </td> </tr> </tbody> </table>
If you are using <input type="text">: 如果您使用的是<input type =“ text”>:
input[type="text"] {
width: 100%;
box-sizing: border-box /* Just in case if you have defined
left or right padding to the input */
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.