如何更改material-ui对话框的位置? [英] How to change the position of material-ui's dialog?

查看:85
本文介绍了如何更改material-ui对话框的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的react应用程序中使用material-ui,打开对话框时是否可以更改位置?现在它总是居中.

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.

提前谢谢!

推荐答案

您可以创建样式并通过 classes 属性传递.这是您如何执行此操作的示例.

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>
  );
}

这篇关于如何更改material-ui对话框的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆