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

标签 javascript html css reactjs fixed-data-table

我在一个面板中有三个表(来自 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 显示器上显示良好,但问题是表格本身无法缩放,所以 f.e.在 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>

关于javascript - 如何使一个 div 中的三个表在调整大小时不重叠?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42243886/

相关文章:

javascript - CSS 目标所有文本转换 : uppercase?

css - 无法在 CSS 和 HTML 中将我的文本 Logo 居中

html - 某些 CSS3 动画在 Firefox 和 IE 中不起作用

html - Bootstrap 改变背景色

javascript - 从数组/Javascript 中删除具有空值的对象

javascript - 谷歌地图 API v3; Web 服务请求和使用 for-loop 显示多个位置

javascript - 打开时用另一个图形替换切换

javascript - 设置 knockout 中的下拉值

javascript - 显示子部分时在父 div 上扩展过渡

html - 你能强制绝对定位的表格单元格堆叠起来,就好像它们没有被从流中取出一样吗?