簡體   English   中英

MaterialUI 基於斷點顯示和隱藏容器的間距

[英]MaterialUI show and hide the Container's gutters based on breakpoints

我想禁用xssmmd的裝訂線。 並在xl及以后啟用它們。

然而,這是行不通的。

    <Container maxWidth={"xl"} disableGutters={{ xs: true, xl: false }}>

我是不是做錯了什么——因為 API 提到 boolean 可以傳遞給disableGutters

正如@Mr.Polywhirl 所說,disableGutters只接受布爾值,您可以按如下方式解決它:

 function Layout({children}) { const theme = useTheme(); const lessThanXL = useMediaQuery(theme.breakpoints.down("xl")); return <Container maxWidth="xl" disableGutters={lessThanXL}>{children}</Container> }

disableGutters道具僅接受 boolean,因此您使用的 API 錯誤。

容器 API - 道具

姓名 類型 默認 描述
disableGutters bool false 如果為true ,則移除左右填充。

所以你的代碼必須看起來像這樣

<Container maxWidth={"xl"} disableGutters={false}>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM