Reactjs 垂直滚动物料界面表体
我正在为我的React.js应用程序使用Material UI表。如果表太长,我想垂直滚动它的主体。这是桌子Reactjs 垂直滚动物料界面表体,reactjs,html-table,material-ui,Reactjs,Html Table,Material Ui,我正在为我的React.js应用程序使用Material UI表。如果表太长,我想垂直滚动它的主体。这是桌子 <Table style={TableBorder}> <colgroup> <col style={{width: '10%'}}/> <col style={{
<Table style={TableBorder}>
<colgroup>
<col style={{width: '10%'}}/>
<col style={{width: '30%'}}/>
<col style={{width: '10%'}}/>
<col style={{width: '10%'}}/>
<col style={{width: '10%'}}/>
<col style={{width: '10%'}}/>
<col style={{width: '10%'}}/>
<col style={{width: '10%'}}/>
</colgroup>
<TableHead>
<TableRow>
<TableCell align="center"
style={styles.table.tableHead.tableCell}>PRODUCT</TableCell>
<TableCell align="center"
style={styles.table.tableHead.tableCell}>BUILDS</TableCell>
<TableCell align="right"
style={styles.table.tableHead.tableCell}>INSTRUCTIONS(%)</TableCell>
<TableCell align="right"
style={styles.table.tableHead.tableCell}>BRANCHES(%)</TableCell>
<TableCell align="right"
style={styles.table.tableHead.tableCell}>COMPLEXITY(%)</TableCell>
<TableCell align="right"
style={styles.table.tableHead.tableCell}>LINES(%)</TableCell>
<TableCell align="right"
style={styles.table.tableHead.tableCell}>METHODS(%)</TableCell>
<TableCell align="right"
style={styles.table.tableHead.tableCell}>CLASSES(%)</TableCell>
</TableRow>
</TableHead>
<TableBody>
{this.state.tableSummary.map((row, index) => (
<TableRow key={index}
style={((row[1] > 0) ? styles.table.tableBody.tableCell.cursorPointer : styles.table.tableBody.tableCell.cursorText)}
hover>
<TableCell component="th" scope="row"
align="left">{row.name}</TableCell>
<TableCell style={builds}
align="left">{formatBuildString(row.build_no)}</TableCell>
<TableCell
align="right">{getPercentage(row.data.totalIns, row.data.missIns)}</TableCell>
<TableCell
align="right">{getPercentage(row.data.totalBranches, row.data.missBranches)}</TableCell>
<TableCell
align="right">{getPercentage(row.data.totalCxty, row.data.missCxty)}</TableCell>
<TableCell
align="right">{getPercentage(row.data.totalLines, row.data.missLines)}</TableCell>
<TableCell
align="right">{getPercentage(row.data.totalMethods, row.data.missMethods)}</TableCell>
<TableCell
align="right">{getPercentage(row.data.totalClasses, row.data.missClasses)}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
但当我使用它时,我的桌子并没有很好地对齐。你们应该以这种方式赋予桌子风格
<Table className="scroll">
....
</Table>
*.css file
.scroll {
height: 100px;
overflow-y: auto;
overflow-x: hidden;
}
or if you customize table with styled component you can do in this way.
const ScrollYTable = styled(Table)̀
height: 100px;
overflow-y: auto;
overflow-x: hidden;
̀
<Table className="scroll">
....
</Table>
*.css file
.scroll {
height: 100px;
overflow-y: auto;
overflow-x: hidden;
}
or if you customize table with styled component you can do in this way.
const ScrollYTable = styled(Table)̀
height: 100px;
overflow-y: auto;
overflow-x: hidden;
̀