如何将组件与中心/右侧对齐 [英] How to align a component to the center/right

查看:53
本文介绍了如何将组件与中心/右侧对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将我的按钮对准父母的右边.

I want to align my button to the right of the parent.

我想知道在material-ui中是否存在正确的方法.我可以使用<Grid container justify="flex-end">,但是随后我必须使用另一个<Grid item />.似乎工作量太大.

I was wondering if there is a proper way to do it in material-ui. I could use a <Grid container justify="flex-end"> but then I would have to use another <Grid item />. Seems too much of work.

或者也许我会更好地使用普通的旧CSS,弄乱float: right并处理元素的明显零高度.

Or maybe I am just better off using plain old CSS, messing around with float: right and dealing with the apparent zero height of the element.

推荐答案

尝试一下

<Grid container alignItems="flex-start" justify="flex-end" direction="row">
     <Button variant="contained">Add account</Button>
</Grid>

这篇关于如何将组件与中心/右侧对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆