Html 如何设置只有垂直单元格间距的表格样式?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3466706/
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-29 04:05:42  来源:igfitidea点击:

How to style table with only vertical cell spacing?

htmlhtml-table

提问by Dean

I have a table in my HTML yet I only want vertical spacing as it doesn't look right with the 25px horizontally. I can see no attribute in HTML to do this so is it possible?
Thanks in Advance,
Dean

我的 HTML 中有一个表格,但我只想要垂直间距,因为水平 25px 看起来不正确。我在 HTML 中看不到任何属性来执行此操作,所以可能吗?
提前致谢,
院长

EDIT: I have a table with cellspacing all the way around of 25px. I would only like vertical cellspacing of 25px.

编辑:我有一个表格,单元格间距一直在 25px 左右。我只想要 25px 的垂直单元格间距。

采纳答案by Robert

the cellpaddingattribute, which I assume you're talking about, will only take a number and use it as pixels between the cell wall and content. You'll have to come up with a workaround, depending on your layout you may want to use a <div>instead, or if there aren't any borders around the cells you can add style='padding-bottom:25px'to it to create the same effect.

cellpadding我假设您正在谈论的属性只会采用一个数字并将其用作单元格壁和内容之间的像素。您必须想出一个解决方法,这取决于您可能想要使用的布局<div>,或者如果单元格周围没有任何边框,您可以添加style='padding-bottom:25px'到它以创建相同的效果。

回答by iamserious

Just add this in the < head > section, just after the head tag opening of your page: This should do the work:

只需在 <head> 部分添加它,就在页面的 head 标签打开之后:这应该可以完成工作:

<style type="text/css">
td { margin: 25px 0px; } /* tells the table to have 25 
px on top and bottom, zero px on left and right */
</style>

回答by javic

I discovered this:

我发现了这一点:

border-bottom: 25px solid transparent;

Be aware that IE6 has a problem with transparency.

请注意 IE6存在透明度问题