【发布时间】:2021-07-26 13:26:50
【问题描述】:
我正在尝试将两个按钮放在右侧。这是我的代码:
export const WalletsContainer = () => {
return (
<Grid style={{ background: 'red' }} direction={'column'} alignItems={'flex-end'}>
<Grid xs={2}>
<CustomButton buttonText={t('add')} onClick={() => console.log('Add')} />
</Grid>
<Grid xs={2}>
<CustomButton buttonText={t('download')} onClick={() => console.log('Download')} />
</Grid>
</Grid>
);
};
这就是它的样子:
我的问题是,为什么现在在右边?基于docs alignItems={'flex-end'} 应该可以解决问题。还是我理解错了?
【问题讨论】:
-
您应该使用
justifyContent="flex-end"而不是alignItems。 -
@PriyankKachhela 这仍然没有帮助。为什么它应该起作用?这违反了文档。它们过时了吗?
-
我认为您在
Grid中缺少container道具。一旦你添加了container属性,它就会以display: flex样式运行,然后它就会像预期的那样工作。在您共享的文档中,有container可用的道具。
标签: javascript css reactjs material-ui