如何在调整大小时使一个div中的三个表不重叠?



我在面板内有三个表(来自 React 的固定数据表)。它运行良好 - 但在较小的分辨率下,三个表将相互重叠。有没有办法使它们可扩展?

下面是返回表的代码:

return (
<div>
<div style = {{position: "absolute", marginTop: "15%", top: "0px", left: "0px", marginLeft: "3%"}}>
<Table
height={35 + ((18) * 30)}
width={280}
rowsCount={firstTable.length}
rowHeight={30}
headerHeight={30}>
<Column
header={<Cell>First</Cell>}
cell={<TextCell data={firstTable} col="first" />}
width={70}
/>
<Column
header={<Cell>Second</Cell>}
cell={<TextCell data={firstTable} col="second" />}
width={105}
/>
<Column
header={<Cell>Third</Cell>}
cell={<TextCell data={firstTable} col="third" />}
width={105}
/>
</Table>
</div>
<div style = {{position: "absolute", marginTop: "15%", top: "0px", right: "0px", marginRight: "3%" }}>
<Table
height={35 + ((secondTable.length) * 30)}
width={280}
rowsCount={secondTable.length}
rowHeight={30}
headerHeight={30}>
<Column
header={<Cell>First</Cell>}
cell={<TextCell data={secondTable} col="first" />}
width={70}
/>
<Column
header={<Cell>Second</Cell>}
cell={<TextCell data={secondTable} col="respBytes" />}
width={105}
/>
<Column
header={<Cell>third</Cell>}
cell={<TextCell data={secondTable} col="third" />}
width={105}
/>
</Table>
</div>
<div style = {{position: "absolute", marginBottom: "10%", bottom: "0px", right: "0", marginRight: "3%" }}>
<Table
height={35 + ((thirdTable.length) * 30)}
width={280}
rowsCount={thirdTable.length}
rowHeight={30}
headerHeight={30}>
<Column
header={<Cell>first</Cell>}
cell={<TextCell data={thirdTable} col="first" />}
width={70}
/>
<Column
header={<Cell>second</Cell>}
cell={<TextCell data={thirdTable} col="second" />}
width={105}
/>
<Column
header={<Cell>third</Cell>}
cell={<TextCell data={thirdTable} col="third" />}
width={105}
/>
</Table>
</div>
</div>

它们在另一个文件中被调用为,使用 react-grid-layout 如下:

<div key={'nicetable'} className = "panel">
<div className="chart-title">
<h3 style={{cursor: "pointer", textAlign: "center"}}>Three tables!</h3>
</div>
<tableExample data={this.state.data.threetabledata } />
</div>

它在 4k 显示器上显示良好,但问题是表格本身无法缩放,因此在 1080p 分辨率下,它们只会相互混淆。由于我使用的是React-grid-layout,您可以在其中调整相应面板的大小,因此需要分辨率的可扩展性,因为用户可以自己更改面板大小。现在,如果将面板变小,则表将相互重叠。

如何使它们调整为父div(可调整大小的面板)?

我对表格缩放字体和所有内容的宽度/高度都很好,因为对于较低分辨率的显示器来说,这甚至会更好。

你可以对div 使用 bootstrap .这是代码。按原样使用。希望它对你有用:-)。

return ( <div> <div className="col-md-3 col-sm-3 col-xs-3" style = {{position: "absolute", marginTop: "15%", top: "0px", left: "0px", marginLeft: "3%"}}> <Table height={35 + ((18) * 30)} width={280} rowsCount={firstTable.length} rowHeight={30} headerHeight={30}> <Column header={<Cell>First</Cell>} cell={<TextCell data={firstTable} col="first" />} width={70} /> <Column header={<Cell>Second</Cell>} cell={<TextCell data={firstTable} col="second" />} width={105} /> <Column header={<Cell>Third</Cell>} cell={<TextCell data={firstTable} col="third" />} width={105} /> </Table> </div> <div className="col-md-3 col-sm-3 col-xs-3" style = {{position: "absolute", marginTop: "15%", top: "0px", right: "0px", marginRight: "3%" }}> <Table height={35 + ((secondTable.length) * 30)} width={280} rowsCount={secondTable.length} rowHeight={30} headerHeight={30}> <Column header={<Cell>First</Cell>} cell={<TextCell data={secondTable} col="first" />} width={70} /> <Column header={<Cell>Second</Cell>} cell={<TextCell data={secondTable} col="respBytes" />} width={105} /> <Column header={<Cell>third</Cell>} cell={<TextCell data={secondTable} col="third" />} width={105} /> </Table> </div> <div className="col-md-3 col-sm-3 col-xs-3" style = {{position: "absolute", marginBottom: "10%", bottom: "0px", right: "0", marginRight: "3%" }}> <Table height={35 + ((thirdTable.length) * 30)} width={280} rowsCount={thirdTable.length} rowHeight={30} headerHeight={30}> <Column header={<Cell>first</Cell>} cell={<TextCell data={thirdTable} col="first" />} width={70} /> <Column header={<Cell>second</Cell>} cell={<TextCell data={thirdTable} col="second" />} width={105} /> <Column header={<Cell>third</Cell>} cell={<TextCell data={thirdTable} col="third" />} width={105} /> </Table> </div> </div>

在表容器中使用calc

div {
width: calc(100% / 3);
}

最新更新