【发布时间】:2020-08-06 10:27:15
【问题描述】:
我正在尝试将一个元素放置在网格项目的末尾(水平方向)。为此,我使用以下 div 组件包装我的组件:
完整代码:
<Grid container spacing={8} alignItems={'stretch'}>
<Grid item xs={9} >
...other components
<div style={{ display: 'flex', flexDirection: 'column', justifyContent: 'flex-end', alignItems: 'flex-end' }}>
<p>hello world</p>
</div>
</Grid>
</Grid>
当我在 Grid 外部使用 div 组件时,元素会浮动到容器的右侧,但在 Grid 内部不起作用。另请注意,此 Grid 是从 Material UI 导入的。任何帮助将不胜感激。谢谢。
【问题讨论】:
-
你可以做一件事。您可以在 Grid 项中添加另一个 Grid 容器,并为您的组件和 div 放置单独的网格项(使用 hello world)。 @Parichay 你明白我的意思了吗?
-
寻求代码帮助的问题必须包含重现它所需的最短代码在问题本身中最好在Stack Snippet 中。见How to create a Minimal, Reproducible Example
标签: html css reactjs flexbox material-ui