How to hide table rows without resizing overall width?

后端 未结 5 1344
粉色の甜心
粉色の甜心 2020-12-19 06:33

Is there a way to hide table rows without affecting the overall table width? I\'ve got some javascript that shows/hides some table rows, but when the rows are set to d

5条回答
  •  南笙
    南笙 (楼主)
    2020-12-19 07:02

    CSS rule visibility: collapse was designed exactly for that.

    tbody.collapsed > tr {
        visibility: collapse;
    }
    

    After adding this CSS you could trigger visibility from JS with:

    tbody.classList.toggle('collapsed');
    

提交回复
热议问题