简体   繁体   English

Material-ui 容器内的抽屉

[英]Material-ui drawer inside a container

How to set material-ui drawer inside a container in reactjs?如何在 reactjs 的容器内设置 material-ui 抽屉?

I wrapped my app page in container with 600px max width.我将我的应用程序页面包装在最大宽度为 600 像素的容器中。 I would like to set the drawer to start into that container not in the body page ( picture ).我想将抽屉设置为从那个容器开始,而不是在正文页面(图片)中。 I am using app bar position as absolute to implement on scroll events, so would not like to change it.我使用 app bar position 作为滚动事件的绝对实现,所以不想更改它。

Here is codesandbox example code: https://codesandbox.io/s/material-drawer-e6vrc?file=/header.js这是codesandbox示例代码: https://codesandbox.io/s/material-drawer-e6vrc?file=/header.js

I found a discussion about it here , but I did not figure out how to make it work in my example.我在这里找到了关于它的讨论,但我没有弄清楚如何让它在我的示例中工作。 From that I tried:从那我试过:

        ModalProps={{
          container: document.getElementById("appContainerDiv"),
          style: { position: "absolute" }
        }}

Ciao, consodering that you set drawerPaper with absolute position, I think the only thing you could do is set your style as:再见,考虑到您将drawerPaper设置为absolute position,我认为您唯一能做的就是将样式设置为:

drawerPaper: {
    minWidth: 100,
    width: "20%",
    position: "absolute",
    right: '12%',
    height: '75%',
  },

and the result will be:结果将是:

在此处输入图像描述

note that this solution is not responsive!请注意,此解决方案没有响应!

Here your code modified. 此处您的代码已修改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM