style problem of Table component with fixed column and scroll attr
See original GitHub issueVersion
2.13.8
Environment
mac and pc; chrome 61;
Reproduction link
https://codepen.io/anon/pen/ooXVNx?editors=0011
Steps to reproduce
const columns = [
{
title: 'col1',
dataIndex: 'col1',
key: 'col1',
width: 100,
},
...
{
title: 'action',
key: 'action',
width: 100,
fixed: 'right',
render: () => <a>click</a>,
}
]
...
<div style={{width: 500}}>
<Table rowKey={r=>r.id} columns={columns} dataSource={data} scroll={{ x: 400 }}/>
</div>
<div style={{width: 300}}>
<Table rowKey={r=>r.id} columns={columns} dataSource={data} scroll={{ x: 400 }}/>
</div>
What is expected?
.
What is actually happening?
当表格的父元素宽度大于表格组件设置的scroll.x的值时,设置了固定表的一列会出现重复的问题;小于或等于scroll.x时正常
当不确定表格的父元素的宽度时,scroll.x不好确定,这样的情况是否有一些解决方法呢?
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Table fixed header and scrollable body - Stack Overflow
Fixed table head - CSS-only. Simply position: sticky; top: 0; your th elements. (Chrome, FF, Edge) .tableFixHead { overflow: auto; height: 100px; }...
Read more >A table with both a sticky header and a sticky first column
It's pretty easy to make the header of a table stick to the top of the screen while scrolling through a bunch or...
Read more >CSS - Aligned scrollable table body with fixed header
The problem. I wanted to include a component that rendered a list of entries that was scrollable whilst having a fixed header.
Read more >How to create a table with fixed header and scrollable body
The purpose of this article is to create a table with a fixed header and scrollable body. We can create such a table...
Read more >table-layout - CSS: Cascading Style Sheets - MDN Web Docs
This can speed up rendering time over the "automatic" layout method, but subsequent cell content might not fit in the column widths provided....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Antd table writes the tags (i.e.,
<th>
and<td>
) of the fixed columns two times: once with the other columns and once in a specific table tag corresponding to the fixed elements.What you need to do is to hide the one which is with the other ones and render only the fixed one. You can do that by overwritting the CSS properties.
Use
visibility: hidden
instead ofdisplay: none
otherwise the column next to the fixed one will go under it.