如何在CSS中指定表填充? (表,不是单元格填充) [英] How do you specify table padding in CSS? ( table, not cell padding )

查看:233
本文介绍了如何在CSS中指定表填充? (表,不是单元格填充)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个有彩色背景的表,我需要指定表格和它的内容之间的填充。细胞。

表标记似乎不接受填充值。

Firebug显示表和tbody的布局,填充为0,但不接受为它们输入的任何值,所以我想他们只是没有padding属性。

但是事情是我想要单元格之间相同的分隔,顶部单元格与表顶部和底部单元格与表格的底部。 >
再次,我想要的不是单元格填充。

I have a table with a colored background and I need to specify the padding between the table and it's content, I.E. cells.
The table tag doesn't seem to accept a padding value.
Firebug shows the table and tbody's layout with padding 0 but doesn't accept any value entered for them, so I guess they just don't have the padding property.
But the thing is I want the same separation between cells than the top cells with the table top and the bottom cells with the table's bottom.
Again, what I want is not cell-padding.

编辑:谢谢,我真正需要,我现在意识到,它的html等价,细胞空间。

但是由于某些原因,他们不在我正在工作的网站做任何事情。

在一个单独的HTML上工作很好,但在

我认为可能是某些样式覆盖属性,但单元格间距和内嵌边框间距不应该被覆盖,对吗?

(I使用firefox)

Thanks, what I really needed, I realize now, was border-spacing, or its html equivalent, cellspacing.
But for some reason, they don't do anything in the site I'm working on.
Both work great on a separate HTML, but in the site they don't.
I thought it could be some style overwriting the property, but cellspacing and an inline border-spacing shouldn't get overwritten, right?
(I use firefox )

编辑2:不,TD填充不是我需要的。使用TD填充,相邻单元格的顶部和底部填充加起来,因此两个单元格之间的空间(实际上是填充)比顶部单元格和表格顶部边界之间的加倍。

EDIT 2: No, TD padding is NOT what I need. With TD padding, top and bottom paddings of adjacent cells sum up, so there's double the space (pad actually) between two cells than between the top cell and the table top border. I want to have exactly the same distance between them.

推荐答案

最简单/最好的支持方法是使用< table cellspacing =10>

The easiest/best supported method is to use <table cellspacing="10">

css方式: border-spacing 由IE我不认为)

The css way: border-spacing (not supported by IE I don't think)

    <!-- works in firefox, opera, safari, chrome -->
    <style type="text/css">
    
    table.foobar {
    	border: solid black 1px;
    	border-spacing: 10px;
    }
    table.foobar td {
    	border: solid black 1px;
    }
    
    
    </style>
    
    <table class="foobar" cellpadding="0" cellspacing="0">
    <tr><td>foo</td><td>bar</td></tr>
    </table>

编辑:单元格内容,而不是空格,您只需使用

if you just want to pad the cell content, and not space them you can simply use

<table cellpadding="10">

td {
    padding: 10px;
}

这篇关于如何在CSS中指定表填充? (表,不是单元格填充)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆