Jer*_*me 1 html-table scrollbar material-ui
我在我的Material-UI的水平滚动条上苦苦挣扎。尽管我阅读了文档并在此处浏览了一些主题,但找不到解决该问题的方法。水平滚动条从不显示。
这是我的代码的子集:
App.js
<div style={{ height: '100vh', overflow: 'auto', width: '600px' }}>
<TableHeader headerlabels={headers} datarows={resu} />
</div >
Run Code Online (Sandbox Code Playgroud)
TableHeader.js
const HeaderTableCell = styled(TableCell)`
&&{
background-color:#092e68;
color:white;
top:0;
position:sticky;
}
`;
const CustomTableCell = styled(TableCell)`
&&{
background-color:white;
color:#092e68;
}
`;
// key, label
const TableHeader = props => {
const { headerlabels, datarows } = props
return (
<Table>
<TableHead >
<TableRow key={uuid.v4()} >
{headerlabels.map((label) =>
(<HeaderTableCell {...props} key={label}>{label}</HeaderTableCell>))}
</TableRow>
</TableHead>
<TableBody >
{datarows.map((value, id) =>
(
<TableRow key={id} >
{headerlabels.map((label) =>
(<CustomTableCell {...props} key={label}>{value[label]}</CustomTableCell>))}
</TableRow>
)
)}
</TableBody >
</Table>
)
};
Run Code Online (Sandbox Code Playgroud)
如果查看Simple Table演示程序的代码,您会看到它通过将Table包裹在Paper中来处理此问题overflowX: 'auto'。
| 归档时间: |
|
| 查看次数: |
3950 次 |
| 最近记录: |