问题描述
在一个HTML表格中,的cellpadding
和 CELLSPACING
可以这样设置:
In an HTML table, the cellpadding
and cellspacing
can be set like this:
<table cellspacing="1" cellpadding="1">
如何可以在同一个实现使用CSS?
How can the same be accomplished using CSS?
推荐答案
基本
有关控制CSS的cellpadding,你可以简单地使用填充
在表格单元格。例如。对于CELLPADDING的10px的:
For controlling "cellpadding" in CSS, you can simply use padding
on table cells. E.g. for 10px of "cellpadding":
td {
padding: 10px;
}
有关CELLSPACING,你可以在边框间距
CSS属性应用到你的表。例如。对于CELLSPACING的10px的:
For "cellspacing", you can apply the border-spacing
CSS property to your table. E.g. for 10px of "cellspacing":
table {
border-spacing: 10px;
border-collapse: separate;
}
此属性将甚至允许单独的水平和垂直间距,有些东西你不能用老派CELLSPACING做的。
This property will even allow separate horizontal and vertical spacing, something you couldn't do with old-school "cellspacing".
问题在IE&LT; = 7
这将工作在几乎所有流行的浏览器,除了互联网和NBSP;浏览器向上穿过互联网&NBSP;&浏览器NBSP; 7,在这里你几乎倒霉。我说几乎是因为这些浏览器依然支持边界崩溃
属性,合并相邻的表格单元格的边框。如果你想消除CELLSPACING(即 CELLSPACING =0
),那么边界崩溃:崩溃
应该具有相同的效果:表格单元之间没有空格。这种支持是越野车,不过,因为它不会覆盖表元素上的现有 CELLSPACING
HTML属性。
This will work in almost all popular browsers except for Internet Explorer up through Internet Explorer 7, where you're almost out of luck. I say "almost" because these browsers still support the border-collapse
property, which merges the borders of adjoining table cells. If you're trying to eliminate cellspacing (that is, cellspacing="0"
) then border-collapse:collapse
should have the same effect: no space between table cells. This support is buggy, though, as it does not override an existing cellspacing
HTML attribute on the table element.
在短期:对于非互联网&NBSP;浏览器5-7浏览器,边框间距
处理你。对于Internet&NBSP;浏览器,如果你的情况是恰到好处(您想0 CELLSPACING和你的表没有它已经定义),您可以使用边界崩溃:崩溃
。
In short: for non-Internet Explorer 5-7 browsers, border-spacing
handles you. For Internet Explorer, if your situation is just right (you want 0 cellspacing and your table doesn't have it defined already), you can use border-collapse:collapse
.
table {
border-spacing: 0;
border-collapse: collapse;
}
注:CSS属性的一个很好的概述,人们可以申请表和它的浏览器,看到这梦幻般的Quirksmode页。
这篇关于设置的cellpadding和CELLSPACING在CSS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!