html table的边框线怎么变圆角_css怎么让表格四角变圆角?

css怎么让表格四角变圆角?下面本篇文章给大家介绍一下使用CSS属性设置table表格圆角的方法。有一定的参考价值,有需要的朋友可以参考一下,希望对大家有所帮助。

使用CSS属性设置table表格圆角

有些情况下需要给表格设置圆角,但是border-radius与border-collapse:collapse;会产生冲突,给table设置border-radius并不会生效。

可以通过减少单元格框线的方式来不设置boder-collapse;collapse; 这样就能给表格添加圆角了。

源码如下:

*{margin: 0;padding: 0;}

table{

margin: 50px auto;

border-spacing: 0;

}

table th{

width: 100px;

height: 30px;

line-height: 30px;

background: gray;

color: white;

}

table td{

width: 100px;

height: 30px;

text-align:center;

line-height: 30px;

}

table tr th:first-child,

table tr td:first-child{

border-left: 1px solid gray; /* 给table设置左边框 */

}

table tr th:last-child,

table tr td:last-child{

border-right: 1px solid gray; /* 给table设置右边框 */

}

table tr td:first-child,

table tr td:nth-child(2),

table tr td:nth-child(3){

border-bottom: 1px solid gray; /* 给tbody各列设置下边框 */

}

table tr:first-child th:first-child{

border-top-left-radius: 10px; /* 设置table左上圆角 */

}

table tr:first-child th:last-child{

border-top-right-radius: 10px; /* 设置table右上圆角 */

}

table tr:last-child td:first-child{

border-bottom-left-radius: 10px; /* 设置table左下圆角 */

}

table tr:last-child td:last-child{

border-bottom-right-radius: 10px;/* 设置table右下圆角 */

}

1-11-21-3

2-12-22-33-13-23-34-14-24-3

效果图如下:

更多web前端知识,请查阅 HTML中文网 !!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值