Ant Design Vue的Table组件设置scroll属性时,表头去掉滚动条

本文介绍了如何通过CSS调整去除Ant Design表格固定头部的垂直滚动条,修复边框问题,并保持美观,同时处理`bordered`属性对阴影的影响。关键代码和逐步解决方案都在文中详细展示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

未去除之前效果:

去除后效果:

只需要去除header的 overflow: scroll属性即可

使用代码:

>>> .ant-table-fixed-header .ant-table-scroll .ant-table-header {
  overflow: hidden!important;
  margin-bottom: 0!important;
  padding-right: 6px;
}

效果如图:

最右侧没有边框,因为:最后一个th右边框颜色透明了,我们给他设置上边框颜色

>>> .ant-table-bordered.ant-table-fixed-header .ant-table-scroll .ant-table-header.ant-table-hide-scrollbar .ant-table-thead > tr:only-child > th:last-child {
  border-right-color: #e8e8e8!important;
}

效果如图:

 

 我这里给table加的有bordered属性,去掉bordered效果如下:

 这就比较完美了,但是如果加上bordered属性,边框外的阴影就比较丑了,如何去掉呢,很简单,

 代码如下:

>>> .ant-table-header {
  background: #fff;
}

最后效果如下图:

 

 完成代码如下:

<style scoped>
  /*去除表头垂直滚动条 begin*/
  >>> .ant-table-fixed-header .ant-table-scroll .ant-table-header {
    overflow: hidden!important;
    margin-bottom: 0!important;
    padding-right: 6px;
  }
  >>> .ant-table-bordered.ant-table-fixed-header .ant-table-scroll .ant-table-header.ant-table-hide-scrollbar .ant-table-thead > tr:only-child > th:last-child {
    border-right-color: #e8e8e8!important;
  }
  >>> .ant-table-header {
    background: #fff;
  }
  /*去除表头垂直滚动条 end*/
</style>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值