当先锋百科网

首页 1 2 3 4 5 6 7

我有一个非常简单的问题。我想做一个从左到右的卡片列表。我的问题是,这张卡现在在中间,当我添加另一张卡时,它会加在下面。我想让它从左到右。

请查看这个codesandbox链接

点击这里

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
    }
  }
}));

Material UI通过网格组件实现了一个非常可爱的网格。把你的牌包在一个& lt网格容器& gt像这样:

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

更新的沙盒。