最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Spacing between TableRow Material-UI - Stack Overflow

programmeradmin3浏览0评论

I would like to add space between TableRow MaterialUI ponents. How can I acplish that?

<S.MainTable>
  <TableBody>
   {rows.map(row => {
     return (
       <S.StyledTableRow key={row.id}>
         <TableCell ponent="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>

I would like to add space between TableRow MaterialUI ponents. How can I acplish that?

<S.MainTable>
  <TableBody>
   {rows.map(row => {
     return (
       <S.StyledTableRow key={row.id}>
         <TableCell ponent="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>
Share Improve this question edited Aug 18, 2018 at 20:36 Abraham 9,9056 gold badges56 silver badges58 bronze badges asked Aug 18, 2018 at 14:38 Евгений КарповичЕвгений Карпович 511 silver badge2 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 6

Add these few lines of code to your table's CSS:

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

you can add spaces between the row of the table by defining paddingBottom and paddingTop in the just like that

<TableCell style={{ paddingBottom: 10, paddingTop: 10 }} colSpan={2}>
           <Collapse in={open} timeout="auto" unmountOnExit>
               <Box margin={1}>
                   <Typography variant="h6" gutterBottom ponent="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 ponent="th" scope="row">
                                       {historyRow.date}
                                   </TableCell>
                                   <TableCell>{historyRow.contact}</TableCell>
                                   <TableCell align="right">{historyRow.staff}</TableCell>
                               </TableRow>
                           ))}
                       </TableBody>
                   </Table>
               </Box>
           </Collapse>
       </TableCell>

Did you used "break" tag? or u can also do with margin and padding .

发布评论

评论列表(0)

  1. 暂无评论