antd滚动表格纵向滚动条问题

问题场景

在使用antd带滚动条的表格时,有时候当tbody的高度≤y值时,纵向滚动条会只留下滚动条背景,滚动条消失(如下图)(有时候空状态也会有问题);只有当tbody的高度高于y值时,纵向滚动条才会正常展示。如果项目中对滚动条进行了样式修改,可能出现不美观的问题。

在这里
插入图片描述

  <Table
    columns={
    
    columns}
    dataSource={
    
    data}
    scroll={
    
    {
    
    
      x: 1500,
      y: 500
    }}
  />

原因和解决方法

antd中的overflow为:

overflow: auto scroll;

y轴的scroll导致了这个问题。

把y轴的属性也改为auto就可以了。

.ant-table-body {
    
    
	overflow: auto !important;
}

猜你喜欢

转载自blog.csdn.net/Charonmomo/article/details/128034545