I have a table with scrollbars and when I filter the table the scrollbars are not showing which is good for me but the problem is the width is changing and the table width is getting bigger. It looks like this:
With scroll bar:
No scroll bar, after filtering:
This is my CSS code:
.table { table-layout: fixed; width: 100% !important; } tbody { display: block; height: 326px; overflow: auto; width: 1205px; } thead, tbody tfoot, tr { display: table; width: 100%; table-layout: fixed; /* even columns width , fix width of table too*/ } thead { table-layout: fixed; } .table tr th:nth-child(1), .table tr td:nth-child(1) { width: 30px !important; } .table tr th:nth-child(2), .table tr td:nth-child(2) { width: 90px !important; } .table tr th:nth-child(3), .table tr td:nth-child(3) { width: 100px !important; } .table tr th:nth-child(4), .table tr td:nth-child(4) { width: 90px !important; } .table tr th:nth-child(5), .table tr td:nth-child(5) { width: 90px !important; } .table tr th:nth-child(6), .table tr td:nth-child(6) { width: 90px !important; } .table tr th:nth-child(7), .table tr td:nth-child(7) { width: 85px !important; } .table tr th:nth-child(8), .table tr td:nth-child(8) { width: 90px !important; } .table tr th:nth-child(9), .table tr td:nth-child(9) { width: 110px !important; } .table tr th:nth-child(10), .table tr td:nth-child(10) { width: 95px !important; }
How to solve my problem?
If you want to ensure that the element does not move when the scrollbar is present, use
Scrollbar gutter onscrollbar-gutter:stable
on the element that has the overflow attribute applied. see below.MDN p>