LoginSignup
26
10

More than 3 years have passed since last update.

material-UI Grid itemの中央寄せ

Last updated at Posted at 2019-08-13

解決策

//grid の親コンポーネント
<Grid container alignItems="center" justify="center">
  <Grid item xs={8}>
    <Tweet />
  </Grid>   
</Grid>

alignItemsとjustifyを指定すればそれだけで中央寄せが可能でした。

冗長なやり方

今までこんな風にめちゃめちゃ冗長にやってたなぁ...

//grid の親コンポーネント
<Grid container alignItems="center" justify="center">
  <Grid item xs={0} md={2}></Grid>
  <Grid item xs={12} md={8}>
    <Tweet />
  </Grid>
  <Grid item xs={0} md={2}></Grid>
</Grid>
26
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
26
10