简体   繁体   English

如何对齐不同的反应组件?

[英]How to align different react components?

I want to achieve the given style.我想实现给定的风格。

想要的图片

Currently, I have目前,我有

这个图片

<Box display="flex" flexDirection="row" alignItems="center" width={1}>
<Box flexGrow="1">
    <Typography variant="h6">
        {subscription.PlanName}
        <Box
            px={1}
            py={0.5}
            color={"primary.contrastText"}
            className={classes.success}
            display="flex"
            alignItems="center"
            justifyContent="space-between"
        >
            {subscription.Status}
        </Box>
    </Typography>
    <Typography variant="caption" component="div">Purchased on: <b>{moment(subscription.StartDate).format("DD-MM-YYYY")}</b></Typography>
    <Typography variant="caption" component="div">Expiring on: <b>{moment(subscription.EndDate).format("DD-MM-YYYY")}</b></Typography>
</Box>
<Box>
    <Button
        variant="outlined"
        color="primary"
        onClick={Actions.openBillingDrawer}>
        UPDATE CREDITS
    </Button>
</Box>
<Box>
    <Button
        variant="contained"
        color="primary"
        onClick={Actions.openBillingDrawer}>
        UPGRADE PLAN
    </Button>
</Box>

Also, the UPDATE CREDITS button is different from which I am currently using.此外, UPDATE CREDITS按钮与我目前使用的不同。 Please provide the correct button for that too.请为此提供正确的按钮。

it is not exactly your goal, but its a good place to start.这不完全是您的目标,但它是一个很好的起点。 You've got the right separation of boxes, right size of the green box and a iconButton:您已经正确分离了框、正确大小的绿色框​​和一个 iconButton:

<Box
  display="flex"
  flexDirection="row"
  alignItems="center"
  width={1}
  justifyContent="space-between"
>
  <Box>
    <Box display="flex" alignItems="flex-end" margin="5px 0">
      <Typography variant="h4" style={{ lineHeight: "0.8" }}>
        Basic Plan
      </Typography>
      <Box
        color="primary.contrastText"
        bgcolor="success.main"
        fontSize="8px"
        padding="2px 4px"
        marginLeft="6px"
      >
        ACTIVE
      </Box>
    </Box>
    <Typography variant="caption" component="div" color="textSecondary">
      Purchased on: <b>01-01-2020</b>
    </Typography>
    <Typography variant="caption" component="div" color="textSecondary">
      Expiring on: <b>02-02-2020</b>
    </Typography>
  </Box>
  <Box>
    <Button
      variant="outlined"
      color="primary"
      endIcon={<ArrowDropDownIcon />}
    >
      UPDATE CREDITS
    </Button>
    <Button variant="contained" color="primary">
      UPGRADE PLAN
    </Button>
  </Box>
</Box>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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