【问题标题】:Having items side by side in a card with Material-UI使用 Material-UI 在卡片中并排放置物品
【发布时间】:2019-12-13 16:48:43
【问题描述】:

我目前正致力于显示用户个人资料的详细信息。我正在尝试使用下面列出的信息设置卡片。我希望这些物品并排放置,而不是在下图中分开它们。

我试过给每个项目一个网格项目,但它只是把它们都列在下面。我想让skillshome phone 并排坐在同一排 与can also workcell phone 并排坐

                        <Grid container spacing={32} justify="center">
                            <Grid item>
                                <PersonImage
                                    personId={metadata.id}
                                    height={175}
                                    width={175}
                                />
                            </Grid>
                            <Grid item style={{ flexGrow: 1 }}>
                                <Grid
                                    container
                                    spacing={0}
                                    direction="column"
                                    justify="center"
                                    alignItems="stretch">
                                    <Grid item xs={6}>
                                        <Card>
                                            <InfoLabel
                                                label="Skills"
                                                text={profile.skills}
                                            />
                                            <InfoLabel
                                                label="Can Also Work"
                                                text={profile.work}
                                            />
                                            <Grid
                                                container
                                                spacing={16}
                                                justify="center">
                                                <Grid item>
                                                    <InfoLabel
                                                        label="Home Phone"
                                                        text={
                                                            contactInfo.homePhone
                                                        }
                                                    />
                                                    <InfoLabel
                                                        label="Cell Phone"
                                                        text={
                                                            contactInfo.mobilePhone
                                                        }
                                                    />

                                                    <InfoLabel
                                                        label="Email"
                                                        text={contactInfo.email}
                                                    />
                                                </Grid>
                                            </Grid>
                                        </Card>

【问题讨论】:

    标签: css flexbox material-ui


    【解决方案1】:

    您可以将 Grid 用于此目的。

    您的网格布局存在一些问题,而且您的间距太高了。间距应小于 12,间距太大会将内容推到下一行,这就是这里发生的情况。

    我创建了一个sandbox 来向您展示如何设置网格。它缺少大部分样式,但布局如您所愿。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-01-12
      • 2021-02-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-20
      • 2015-09-18
      相关资源
      最近更新 更多