亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Material UI 網格:在更寬的屏幕上按鈕之間需要空間

Material UI 網格:在更寬的屏幕上按鈕之間需要空間

慕容708150 2023-11-02 21:31:06
我有一個非常簡單的布局,我需要在寬屏幕上并排放置兩個按鈕。然而,我需要它們之間有大約 10 像素的距離,不幸的是,添加邊距會將按鈕推到一邊。我認為添加justify='space-between可以解決這個問題,但它沒有任何作用。這就是我的代碼的樣子:const MyComponent = () => (    <div style={{ width: 500 }}>        <div style={{ width: '100%' }}>            <Grid container justify='space-between'>                <Grid item xl={6} lg={6} md={6} sm={12} xs={12}>                    <Button variant='contained'>                        Left Side Button                    </Button>                </Grid>                <Grid item xl={6} lg={6} md={6} sm={12} xs={12}>                    <Button variant='contained'>                        Right Side Button                    </Button>                </Grid>            </Grid>        </div>    </div>)結果如下:不管怎樣,我怎樣才能在它們之間添加大約 10 像素而不讓它們也被推開 10 像素呢?
查看完整描述

1 回答

?
守著星空守著你

TA貢獻1799條經驗 獲得超8個贊

您可以在父容器上設置間距屬性:

<Grid container spacing={2} justify='space-between'>

這應該會增加所有子元素之間的間距。盡管它應用 8px 倍數的間距。因此,如果您恰好需要 10px,則必須在自定義主題中覆蓋該屬性。

這是該道具的文檔spacing

https://material-ui.com/components/grid/#spacing


查看完整回答
反對 回復 2023-11-02
  • 1 回答
  • 0 關注
  • 112 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號