简体   繁体   中英

What is the best way for custom spacing between rows in material-ui grid?

what is the best way to have a spacing between certain rows within a grid in material-ui?

For example, given the following grid with spacing={0} .

GridContainer
row1    GridItem GridItem
row2    GridItem GridItem
row3    GridItem GridItem
row4    GridItem GridItem

The goal is to have the same grid with spacing of 0, but with custom spacing between rows 2 and 3

GridContainer
row1    GridItem GridItem
row2    GridItem GridItem

row3    GridItem GridItem
row4    GridItem GridItem

I tried to put mt={2) to GridItems in the 3rd row but it did not work. I achieved the behaviour with a custom class passed via the className attribute, though I am not sure if this is the best way to go.

Cheers

<Grid container layout={"row"} spacing={10} >
   <Grid item xs={12} md={3}>
      <div style={{height: "100%", paddingTop: 5}}>add your component here</div>
   </Grid>
</Grid>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM