卡清单反应材料

时间:2020-06-24 05:14:00

标签: css reactjs jss react-material

我有一个非常简单的问题。我想从左到右列出一张卡片清单。我的问题是该卡现在位于中间,当我添加另一张卡时,它会在下面累加。我希望它从左到右都是这样。

请参见此代码和框链接

CLICK HERE

const useStyles = makeStyles(theme => ({
  root: {
    display: "flex",
    justifyContent: "initial"
  },
  title: {
    marginBottom: "30px"
  },
  header: {
    marginBottom: "20px",
    display: "flex",
    alignItems: "center",
    justifyContent: "space-between"
  },
  card: {
    maxWidth: 300,
    margin: "auto",
    transition: "0.3s",
    boxShadow: "0 8px 40px -12px rgba(0,0,0,0.3)",
    "&:hover": {
      boxShadow: "0 16px 70px -12.125px rgba(0,0,0,0.3)"
    }
  },
  media: {
    paddingTop: "56.25%"
  },
  content: {
    textAlign: "left",
    padding: theme.spacing.unit * 3
  },
  divider: {
    margin: `${theme.spacing.unit * 3}px 0`
  },
  heading: {
    fontWeight: "bold"
  },
  subheading: {
    lineHeight: 1.8
  },
  avatar: {
    display: "inline-block",
    border: "2px solid white",
    "&:not(:first-of-type)": {
      marginLeft: theme.spacing.unit
    }
  }
}));

1 个答案:

答案 0 :(得分:0)

材质UI通过Grid组件具有非常漂亮的网格实现。只需将卡包裹在<Grid container>中,如下所示:

  <Grid container>
    <Card className={classes.card}>
      ...
    </Card>
  </Grid>

Updated sandbox.