html - 在表格单元格内使输入文本字段全宽

标签 html css

http://jsfiddle.net/p1my39fh/

table {
    width: 550px;
    border-collapse:collapse;
    margin: auto;
    background-color: #A4A4A4;
    border: 2px solid black;
    padding: 0;
}
table td {
    position: relative;
    text-align: center;
    border: 2px solid green;
    padding: 0;
    margin: 0;
}
<table>
    <tr>
        <td><input type="text" size="30"/></td>
        <td>Test Information</td>
    </tr>
</table>

如何删除 <input> 周围的空格? ?

我怎样才能同时制作 <td>宽度相同吗?

最佳答案

使两者<td> s 具有相同的宽度,您可以设置:

table {
    width: 550px;
    table-layout: fixed;
}

拥有<input>填充 <td> 的整个宽度,你可以设置:

input {
    width: 100%;
    box-sizing: border-box;
}

更新的演示:

table {
    width: 550px;
    border-collapse:collapse;
    margin: auto;
    background-color: #A4A4A4;
    border: 2px solid black;
    table-layout: fixed;
}
td {
    text-align: center;
    border: 2px solid green;
}
td input {
    width: 100%;
    box-sizing: border-box;
}
<table>
    <tr>
        <td><input type="text" size="30"/></td>
        <td>Test Information</td>
    </tr>
</table>

关于html - 在表格单元格内使输入文本字段全宽,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30786613/

相关文章:

HTML/CSS Z :index Position:Relative Question

html - Sass 和第一个元素

javascript - 菜单链接在手机/平板电脑中不起作用

html - 崇高文本 2 : How to search for every instance of an applied class?

html - 按页面长度更改侧边栏高度

javascript - 如何清除和更改 Canvas 的背景颜色?

php - 显示一个字段作为主表头的mysql表

php - HTML5 音频流

javascript - Ionic 4 D3 样式与 scss 类

javascript - 从元素中删除类不会触发 css 动画