问题
Using material-ui in my react app, is there a way I can change the position when the dialog is opened? now it's always centered.
Thanks in advance!
回答1:
You can create styles and pass it through classes
prop. Here is an example of how you could do that.
import React from 'react';
import { makeStyles, Dialog } from '@material-ui/core';
const useStyles = makeStyles({
dialog: {
position: 'absolute',
left: 10,
top: 50
}
});
function Example() {
const classes = useStyles();
return (
<Dialog
classes={{
paper: classes.dialog
}}
/* rest of the props */
>
{/* content of the dialog */}
</Dialog>
);
}
来源:https://stackoverflow.com/questions/61439557/how-to-change-the-position-of-material-uis-dialog