[英]Material-UI Dialog How to place the close button on the top right border of the dialog
一些注意點:
position: 'absolute'
以啟用調整close button
的 position。
overflowY: 'unset'
通過覆蓋相關的樣式道具paper
來啟用對話框外溢出。
將 MUI IconButton
與圖標CloseIcon
用於需求 UI。
使用 MUI makeStyles
樣式掛鈎自定義 styles。
參考:
MUI對話框 CSS API :紙
MUI styles 解決方案:makeStyles
示例代碼:
import { makeStyles } from "@material-ui/core/styles";
const useStyles = makeStyles(theme => ({
paper: {
overflowY: 'unset',
},
customizedButton: {
position: 'absolute',
left: '95%',
top: '-9%',
backgroundColor: 'lightgray',
color: 'gray',
}
}));
import CloseIcon from '@material-ui/icons/Close';
import { IconButton } from '@material-ui/core';
<Dialog
classes={{paper: classes.paper}}
>
<DialogActions>
<IconButton className={classes.customizedButton}>
<CloseIcon />
</IconButton>
...
</DialogActions>
</Dialog>
在線演示:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.