简体   繁体   English

如何制作按钮,输入填充整个表格单元格? 留下微小的缝隙

[英]how do I make button, input fill entire table cell? slight gaps are left

I am trying to fill an entire table cell with a button and another cell with a drop-down list. 我正在尝试用按钮填充整个表格单元格,并用下拉列表填充另一个单元格。

If you have a look at my JSFiddle, I am having troubles with a slight gap between the cells and the table border. 如果您看一下我的JSFiddle,单元格和表格边框之间的细微间隙会给我带来麻烦。

I have tried several different approaches but I can't seem to figure out how to remove the gap. 我尝试了几种不同的方法,但是我似乎无法弄清楚如何消除差距。

Any help with this would be appreciated. 任何帮助,将不胜感激。 Thank you! 谢谢!

input, select {
    margin:0;
    padding:0;
    height:100%;
    width:100%;
}

JSFiddle JSFiddle

If you mean the big spaces above and below the input and select box then you can solve this by adding height:auto to tr tag instead of height: 100px . 如果您是指输入和选择框上方和下方的大空格,则可以通过在tr标签中添加height:auto而不是height: 100px来解决此问题。

If you mean that you want the input and select to touch the border then you can add padding: 0px to td tag. 如果您要输入并选择触摸边框,则可以向td标签添加padding: 0px

JSFiddle JSFiddle

Your padding:0 need to be on td, not tr, so 您的padding:0必须在td而不是tr上,所以

td {
    padding: 0;
}

and with the button, the browser builds in a space for styling, so if you want it to be full you can do: 并使用按钮,浏览器将在样式空间中构建,因此,如果您希望它充满空间,则可以执行以下操作:

input[type=button]{ 
    border: solid 1px #ccc;
}

you will lose the 3d effect on the button though 您将失去按钮上的3d效果

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM