HTML 表格单元格间距或填充只是顶部/底部

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/394698/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 22:55:26  来源:igfitidea点击:

HTML Table cellspacing or padding just top / bottom

htmlhtml-table

提问by leora

Can you have cellpadding or spacing just on the top/ bottom as opposed to all (T, B, L, R) ?

与所有 (T, B, L, R) 相比,您可以在顶部/底部设置单元格填充或间距吗?

回答by TRF

CSS?

CSS?

td {
  padding-top: 2px;
  padding-bottom: 2px;
}

回答by Nathan Moos

There is css:

有CSS:

table { border-spacing: 40px 10px; }

for 40px wide and 10px high

40px 宽和 10px 高

回答by Robert C. Barth

Cellspacing is all around the cell and cannot be changed (i.e. if it's set to one, there will be 1 pixel of space on all sides). Padding can be specified discreetly (e.g. padding-top, padding-bottom, padding-left, and padding-right;or padding: [top] [right] [bottom] [left];).

Cellspacing 围绕着单元格,不能改变(即如果它设置为 1,则所有边都有 1 像素的空间)。可以谨慎地指定填充(例如padding-toppadding-bottompadding-left、 和padding-right;padding: [top] [right] [bottom] [left];)。

回答by datasn.io

This might be a little better:

这可能会好一点:

td {
  padding:2px 0;
}