【问题标题】:Spacing between TableRow Material-UITableRow Material-UI 之间的间距
【发布时间】:2019-01-25 08:14:27
【问题描述】:

我想在 TableRow MaterialUI 组件之间添加空格。我怎样才能做到这一点?

<S.MainTable>
  <TableBody>
   {rows.map(row => {
     return (
       <S.StyledTableRow key={row.id}>
         <TableCell component="th" scope="row">{row.name}</TableCell>
         <TableCell numeric>{row.calories}</TableCell>
         <TableCell numeric>{row.fat}</TableCell>
         <TableCell numeric>{row.carbs}</TableCell>
         <TableCell numeric>{row.protein}</TableCell>
       </S.StyledTableRow>
           );
         })}
  </TableBody>
</S.MainTable>

【问题讨论】:

    标签: javascript css reactjs material-ui jsx


    【解决方案1】:

    你使用过“break”标签吗?或者你也可以使用边距和填充。

    【讨论】:

    • 请通过示例或代码详细说明您的答案。
    【解决方案2】:

    将这几行代码添加到表格的 CSS 中:

    {
         border-spacing: 0 5px !important;
         border-collapse: separate !important;
    }
    

    【讨论】:

      【解决方案3】:

      你可以通过定义 paddingBottom 和 paddingTop 在表格的行之间添加空格

      <TableCell style={{ paddingBottom: 10, paddingTop: 10 }} colSpan={2}>
                 <Collapse in={open} timeout="auto" unmountOnExit>
                     <Box margin={1}>
                         <Typography variant="h6" gutterBottom component="div">
                             ENGAGEMENT HISTORY
                 </Typography>
                         <Table size="small" aria-label="purchases">
                             <TableHead>
                                 <TableRow>
                                     <TableCell>Date</TableCell>
                                     <TableCell>Club</TableCell>
                                     <TableCell align="right">Staff</TableCell>
                                 </TableRow>
                             </TableHead>
                             <TableBody>
                                 {row.engagementHistory.map((historyRow) => (
                                     <TableRow key={historyRow.date}>
                                         <TableCell component="th" scope="row">
                                             {historyRow.date}
                                         </TableCell>
                                         <TableCell>{historyRow.contact}</TableCell>
                                         <TableCell align="right">{historyRow.staff}</TableCell>
                                     </TableRow>
                                 ))}
                             </TableBody>
                         </Table>
                     </Box>
                 </Collapse>
             </TableCell>
      

      【讨论】:

      • 可以添加沙箱吗?它现在似乎不起作用!
      • 是的,你还在寻找那个问题的答案吗?如果是,那么我会为你做那件事
      • 你能提供正确答案吗?我正在寻找同样的答案
      猜你喜欢
      • 2017-02-07
      • 2019-10-17
      • 2021-06-05
      • 1970-01-01
      • 2016-06-09
      • 2021-10-10
      • 1970-01-01
      • 2019-11-14
      • 1970-01-01
      相关资源
      最近更新 更多