控制表格单元之间的间距 [英] Controlling Spacing Between Table Cells

查看:129
本文介绍了控制表格单元之间的间距的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建一个表,其中每个单元格都有背景颜色,它们之间有空格。但我似乎有麻烦这样做。

I'm trying to create a table where each cell has a background color with white space between them. But I seem to be having trouble doing this.

我尝试设置 td 边距,但似乎没有效果。

I tried setting td margins but it seems to have no effect.

table.myclass td {
    background-color: lime;
    margin: 12px 12px 12px 12px;
}​

如果我使用padding做同样的事情,

If I do the same thing with padding, it works, but then I don't have the spacing between cells.

有人可以帮我解决这个问题吗?

Could someone help me with this?

jsFiddle: http://jsfiddle.net/BfBSM/

jsFiddle: http://jsfiddle.net/BfBSM/

推荐答案

使用 border-spacing

确保 border-collapse 设置为单独(或根本不会有任何间距)。

Make sure border-collapse is set to separate (or there won't be any spacing at all).

这篇关于控制表格单元之间的间距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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