【发布时间】:2022-01-08 14:33:07
【问题描述】:
我一直在使用 MUI 的 popper API,并注意到它溢出了我的主 div。任何人都可以提出阻止这种情况的最佳方法吗?
我希望 popper 的高度更大。请看下面:
const DescriptionEditor = (props) => {
const [anchorEl, setAnchorEl] = React.useState(null);
const [open, setOpen] = React.useState(false);
const [placement, setPlacement] = React.useState();
const handleClick = (newPlacement) => (event) => {
setAnchorEl(event.currentTarget);
setOpen((prev) => placement !== newPlacement || !prev);
setPlacement(newPlacement);
};
<Box sx={{ width: 200 }}>
<Popper open={open} anchorEl={anchorEl} placement={placement} transition>
{({ TransitionProps }) => (
<Fade {...TransitionProps} timeout={350}>
<Paper>
<Typography variant="subtitle3">WWF values diversity and is building a workforce that reflects the community we serve.</Typography>
</Paper>
</Fade>
)}
</Popper>
<Grid container justifyContent="center">
<Button onClick={handleClick('bottom')} variant="subtitle2" color="primary">Corporate Profile</Button>
</Grid>
</Box>
}
如果有人知道限制这一点的好方法,可能是通过 maxWidth 函数或 100% 属性在父 div 中,请告诉我!!
【问题讨论】:
标签: javascript reactjs material-ui