css3中border-bottom-xxx-radius不生效问题+表格美化问题

关于table表格中圆角不生效的问题
某天我写了一个表格长这样:
在这里插入图片描述
问题来了我设置了四个角的圆角,但是最后没生效!并且th和td错开了一像素看起来非常不舒服。
代码如下:

.computedtable  th:first-child {
    border-top-left-radius: 12px;
}
.computedtable  th:last-child {
    border-top-right-radius: 12px;
}
.computedtable tr:last-child td:first-child {
    border-bottom-left-radius:12px;
}
.computedtable tr:last-child td:last-child {
    border-bottom-right-radius: 12px;
}

查询原因之后发现是给表格设置的这个属性导致: border-collapse:collapse;
划重点划重点划重点!!!!!!!!!!

border-collapse:collapse和border-radius不兼容!!!!!!!!!!!
不兼容!! 不兼容!! 不兼容!! 不兼容!!

既然不能合并,于是修改属性: border-collapse:separate;
设置之后还有一点美观上的问题,表头和表身错开,比如border重合了:在这里插入图片描述
解决方法:给td、按照所处位置设置border,eg:

.computedtable th:nth-child(-n+4){
    border-left: 1px solid white;
}
.computedtable tr th:nth-child(1){
    border-left:1px solid  #ffaa00 ;
}
.computedtable tr td{
    border-bottom: 1px solid  #ffaa00 ;
    border-left: 1px solid  #ffaa00 ;
}
.computedtable tr td:last-child,.computedtable tr th:last-child{
    border-right: 1px solid  #ffaa00;
}

对齐了!!!治好了我的强迫症!一个漂漂亮亮的表格就做好啦~都是小细节上的功夫在这里插入图片描述

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值