我正在嘗試為MUI折疊組件設置寬度:100%。我的組件結構如下。應用style = { { width:& quot;100% & quot;}}直接就可以了。但是當我創建一個單獨的樣式組件時,它不起作用。
<Accordion defaultExpanded style={{ width: "100%" }}>
<StyledAccordionSummary>
<Typography noWrap>
{name}
</Typography>
{filterComponent}
</StyledAccordionSummary>
<StyledAccordionDetails>
<List>{children}</List>
</StyledAccordionDetails>
</Accordion>
以下不起作用:
export const StyledAccordion = styled(Accordion)(() => ({
'& .MuiPaper-root': {
width: "100%"
},
}));
<StyledAccordion>
.....
</StyledAccordion>
是因為這個類不僅包含了MuiPaper-root,還包含了下面的內容嗎?
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation1
MuiAccordion-root MuiAccordion-rounded Mui-expanded MuiAccordion-gutters css-
g8v8pi-MuiPaper-root-MuiAccordion-root"
下一篇3態CSS撥動開關