【问题标题】:mui grid 2 items per rowmui grid 2 items per row
【发布时间】:2022-12-02 06:28:28
【问题描述】:

I'm trying to get only 2 items per row but I keep getting them all on the same row.

return (
    <div>
      <Grid container item xs={12} spacing={-1}>
   
      ...
      <Grid container item spacing={2}>
      ...

          <h1> Uspar</h1>
          <Box sx={{ width: '100%' }}>
            <Box className={classes.productsWrapper}>
              {PRODUCTS.map((item, index) => (
                <Button className={classes.productItem} key={index}>
                  <img className={classes.productImage} src={item.img} />
                  <h1> {item.Title}</h1>
                  <h2> {item.Subtitle}</h2>
                  <Typography variant="body1">{item.description}</Typography>
                </Button>
              ))}
            </Box>
          </Box>
        </Grid>
      </Grid>
    </div>
  );
}

I have tried

grit item xs{6}

etc.

【问题讨论】:

标签: material-ui react-tsx


【解决方案1】:

You should call the map function outside the grid. Try this way : https://codesandbox.io/s/wispy-bush-xme0f0?file=/src/App.js

【讨论】:

  • Thanks but it got really big you know a way to make it smaller?
  • What is it you want to shrink?
  • the images went really big and changign the width and height of them doesnt change it
  • Check again, I think you want something like this.
猜你喜欢
  • 2020-05-20
  • 1970-01-01
  • 2016-10-21
  • 1970-01-01
  • 2022-12-28
  • 1970-01-01
  • 2022-08-15
  • 2023-02-10
  • 2013-06-27
相关资源
最近更新 更多