抽屉标题中的antd浮动图标

Antd floating icon in the tittle of Drawer

我想制作一个绝对定位的元素(一个图标)以浮动在 Antd Drawer 标题中,但它被剪切超出了模态。

我试图在 div 和抽屉道具中给它无限 z-index 但没有成功。

我附上了一个codesanbox,这样我就可以解释我的观点,你可以玩一下。

我错过了什么?

Codesandbox example

Is this what you want to achieve?

如果是,就给父容器一个position: relative:)

z-index 将不起作用,除非该元素的位置已设置。您正在提供 z-index 但没有将位置提供给抽屉。请给抽屉position: relative;

好的,我找到了!

最后它比我尝试过的其他方法更简单... 当您必须使用新库时,这总是很棘手。不管怎样,我更新了 codesandbox 所以你可以看到它在工作!

神奇之处在于:

.ant-drawer-open .ant-drawer-content-wrapper {
  overflow: visible;
}

.ant-drawer-open .ant-drawer-content {
  overflow: visible;
}