CSS表边框间距只有内部 [英] CSS table border spacing inside only

查看:132
本文介绍了CSS表边框间距只有内部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试过几个月了,Google没有帮助我。我试图在表中的< td> < th> 我做,它在外面做间距。因此,表不与任何其他内联。所以它看起来像表有一些填充。

I have trying to work this out for months, and Google hasn't helped me. I'm trying to have spacing between <td> and <th> tags in a table, but when I do, it does spacing in the outside. Therefore, the table isn't inline with anything else. So it looks like the table has some padding.

我似乎找不到解决方案。

I can't seem to find a solution.

这里是问题的示例

推荐答案

有同样的问题,边框间距属性也增加了表周围的空间,据我所知,没有任何限制为只有‘里面&rsquo,所以我使用透明边框:

Had the same problem, the border spacing property was adding space around the table as well, and to my knowledge, there wasn’t anyway to limit it to only ‘the inside’, so I used transparent borders instead:

table td {
   border-left: 1em solid transparent;
   border-top: 1em solid transparent;
}

这会设置‘边框间距’正常情况下,除了不需要的’

This sets ‘border spacing’ as normal, except that there’s ‘unwanted’ spacing at the top and left of the table.

table td:first-child {
   border-left: 0;
}

选择第一列。

table tr:first-child td {
   border-top: 0;
}

选择第一行的td元素的表从一个tr元素开始,相应地改变th)

Selects the td elements of the first row (assuming that the top of the table starts with a tr element, change accordingly for th).

这篇关于CSS表边框间距只有内部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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