CSS:仅在表列之间的边界 [英] CSS: borders between table columns only

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

问题描述

有没有办法使用CSS在列之间的列中显示边框(而不是在外边缘)?

解决方案

不是没有棘手的CSS选择器和额外的标记等。



这样做可能会使用CSS选择器:

 表{
border:none;
border-collapse:collapse;
}

表td {
border-left:1px solid#000;
border-right:1px solid#000;
}

表td:first-child {
border-left:none;
}

表td:last-child {
border-right:none;
}

编辑

为了澄清@ jeroen的注释,你真正需要的是:

 没有; border-collapse:collapse; } 
table td {border-left:1px solid#000; }
table td:first-child {border-left:none; }


Is there a way, using CSS, to show borders in a table between columns only (not on the outer edges)?

解决方案

Not without tricky css selectors and extra markup and the like.

Something like this might do (using CSS selectors):

table {
border:none;
border-collapse: collapse;
}

table td {
border-left: 1px solid #000;
border-right: 1px solid #000;
}

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

table td:last-child {
border-right: none;
}

Edit

To clarify @jeroen's comment blow, all you'd really need is:

table { border: none; border-collapse: collapse; }
table td { border-left: 1px solid #000; }
table td:first-child { border-left: none; }

这篇关于CSS:仅在表列之间的边界的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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