抽屉可以永久放置并覆盖内容吗?

时间:2019-05-10 11:02:43

标签: reactjs typescript navigation-drawer material-ui

我想在屏幕左侧放置一个迷你抽屉,就像Material UI Documentation上的示例一样:

enter image description here

但是对于我来说,我希望它在打开时浮动在内容上(例如组件的variant="temporary"版本),因为当前它会推送内容。

如果我使用open道具来动态更改变体样式,它看起来就不会很好。

有什么办法可以做到这一点?

1 个答案:

答案 0 :(得分:0)

如果这样设置内容的样式,则将其位置设置为绝对值时,其位置将不受抽屉状态的影响。

content: {
    position: "absolute",
    marginLeft: theme.spacing.unit * 7 + 1,
    padding: theme.spacing.unit * 3
  }

打开抽屉时,标题文本当然会向左移动。

编辑:我要离开这里的迷你型抽屉的代码整理箱Material UI demo