skip to Main Content

I ‘m using Ant Design’s Table component to display a considerable number of rows per page. The problem I’m facing is that the horizontal scroll is way at the bottom of the page. Is there a way to position the horizontal scroll bar on the top of the Table, instead of default behavior which is at the bottom.

I tried the docs but nothing related showed up.
Thanks in advance!

2

Answers


  1. You have try it

    .custom-table-container {
      direction: rtl;
     }
    
    .custom-table-container .ant-table {
      direction: ltr;
    }
    
    .custom-table-container .ant-table-body::-webkit-scrollbar {
      width: 12px;
    }
    
    .custom-table-container .ant-table-body::-webkit-scrollbar-track {
      background: #f1f1f1;
    }
    
    .custom-table-container .ant-table-body::-webkit-scrollbar-thumb {
      background: #888;
    }
    .custom-table-container .ant-table-body::-webkit-scrollbar-thumb:hover {
      background: #555;
    }
    

    but I recommend using scroll X so that the width of the table is not too big compared to your screen

    Login or Signup to reply.
  2. I faced the same problem, and there is no native way to do it with AntD, but it can be done using CSS rotateX, here’s how I solved it:

    /* Rotate ant-table-body & its children table. */
    .ant-table-body,
    .ant-table-body > table,
    .ant-table-fixed-right, /* If you're also using fixed columns, rotate them too. Both the container ant-table-fixed-right/left & its children ant-table-body-outer. */
    .ant-table-fixed-right > .ant-table-body-outer,
    .ant-table-fixed-left,
    .ant-table-fixed-left > .ant-table-body-outer {
      transform: rotateX(180deg);
    }
    
    /* If you're using fixed columns, they will be misaligned with the rest of the table when the scroll bar is on top, so apply this to fix it. */
    .ant-table-fixed-right,
    .ant-table-fixed-left {
      height: 100%;
    }
    

    I took it from here: https://www.geeksforgeeks.org/how-to-change-the-position-of-scrollbar-using-css/

    And here’s also a modified demo using this scroll top if you wanna try it first: https://codepen.io/laura-e24/pen/YzbWdxO

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search