在HTML表格中,单元格填充和单元格间距可以这样设置:
<table cellspacing="1" cellpadding="1">
如何使用CSS实现这一点?
在HTML表格中,单元格填充和单元格间距可以这样设置:
<table cellspacing="1" cellpadding="1">
如何使用CSS实现这一点?
当前回答
我用过!在边境崩溃后很重要
border-collapse: collapse !important;
它在IE7中对我有用。它似乎覆盖了cellspacing属性。
其他回答
我用过!在边境崩溃后很重要
border-collapse: collapse !important;
它在IE7中对我有用。它似乎覆盖了cellspacing属性。
用div包装单元格的内容,你可以做任何你想做的事情,但你必须将每个单元格包装在一列中,以获得统一的效果。例如,要获得更宽的左右边距:
因此CSS将是,
div.cell加宽器{边距:0px 15px 0px 15像素;}时差{填充:0px;}<table border=“0”><tr><td class=“紧”><div class=“cellwider”>我的内容</div></td></tr></table>
是的,这很麻烦。是的,它适用于Internet Explorer。事实上,我只在Internet Explorer上测试过这一点,因为这是我们在工作中允许使用的全部功能。
此外,如果您希望cellspacing=“0”,请不要忘记在表的样式表中添加边框折叠:折叠。
此样式用于表格的完全重置-单元格填充、单元格间距和边框。
我的reset.css文件中有这样的样式:
table{
border:0; /* Replace border */
border-spacing: 0px; /* Replace cellspacing */
border-collapse: collapse; /* Patch for Internet Explorer 6 and Internet Explorer 7 */
}
table td{
padding: 0px; /* Replace cellpadding */
}
td {
padding: npx; /* For cellpadding */
margin: npx; /* For cellspacing */
border-collapse: collapse; /* For showing borders in a better shape. */
}
如果边距不起作用,请尝试将tr的显示设置为块,然后边距将起作用。