我如何在y轴上偏移Material-UI Popper(popper.js库)的位置?

问题描述 投票:0回答:1

enter image description here

我在如上所述的“弹出”菜单中使用了Material-ui(v 4.9.5)PopperanchorElement是左侧选择的ListItem。我希望Popper与主菜单的顶部平齐。但是它看起来短了5px。

[如果我查看Chrome开发工具,则会看到以下内容,而5px参数中的translate3d值就是问题。如果我在开发工具中将值更改为0px,问题就解决了。

enter image description here

我的问题是如何通过代码实现这一点。我已经尝试使用modifiers作为底层popper.js的以下内容,并且它无所事事

 <Popper
    modifiers={{
        offset: {
         enabled: true,
         offset: '-5, 0'
    },
    }}
    className={globalMenuStyle.popperStyle}
    placement="right-end"
    open={isPopoverOpen}
    onClose={handleHidingGlobalMenu}
    anchorEl={anchorElement}>
    {popoverMenuItems}
 </Popper>

甚至更陌生的是,如果我尝试并尝试类似的操作,然后尝试将modifiers的x轴移动,它会沿x轴移动。 为什么x轴不起作用,而y轴不起作用?

modifiers={{
   offset: {
    enabled: true,
    offset: '0, 50'
},
}}

enter image description here

javascript css reactjs material-ui popper.js
1个回答
0
投票

使用popperOptions属性为popper.js实例提供选项obj,如下所示:

popperOptions
© www.soinside.com 2019 - 2024. All rights reserved.