admin管理员组文章数量:1187319
I'm using Material UI v4.9.1. They have a Popper
React component, based on Popper.js v1.14.1.
I'm trying to render a small square card on the bottom right corner of my browser.
With plain CSS, I think I would have to do this.
.card {
position: 'fixed';
bottom: 0;
right: 0;
}
I was trying to do that with the Popper
component, but I'm not sure how. This is what I have now.
<Popper
open={anchor !== null}
placement="bottom-end"
anchorEl={anchor}
popperOptions={{positionFixed: true}}
modifiers={{
// I think I need some modifier?...
}}
>
{/* card component */}
</Popper>
I'm setting anchor = document.body
when the user clicks a button. I've also set
html, body {
width: 100%;
}
in my root index.html
.
However, when the Popper
appears it's in the top right corner. The div
has this style set.
position: fixed;
top: 0px;
left: 0px;
transform: translate3d(1164px, 5px, 0px);
will-change: transform;
What am I missing?
I'm using Material UI v4.9.1. They have a Popper
React component, based on Popper.js v1.14.1.
- https://material-ui.com/api/popper
- https://popper.js.org/docs/v1
I'm trying to render a small square card on the bottom right corner of my browser.
With plain CSS, I think I would have to do this.
.card {
position: 'fixed';
bottom: 0;
right: 0;
}
I was trying to do that with the Popper
component, but I'm not sure how. This is what I have now.
<Popper
open={anchor !== null}
placement="bottom-end"
anchorEl={anchor}
popperOptions={{positionFixed: true}}
modifiers={{
// I think I need some modifier?...
}}
>
{/* card component */}
</Popper>
I'm setting anchor = document.body
when the user clicks a button. I've also set
html, body {
width: 100%;
}
in my root index.html
.
However, when the Popper
appears it's in the top right corner. The div
has this style set.
position: fixed;
top: 0px;
left: 0px;
transform: translate3d(1164px, 5px, 0px);
will-change: transform;
What am I missing?
Share Improve this question asked Feb 7, 2020 at 23:01 425nesp425nesp 7,58311 gold badges54 silver badges63 bronze badges5 Answers
Reset to default 15check offset
<Popper
className='popper-root'
open={open}
anchorEl={anchorEl}
placement='bottom-end'
modifiers={{
offset: {
enabled: true,
offset: '0, 30'
}
}}
>
You can try to set css on Popper
.
<Popper
open={anchor !== null}
style={{ position: 'fixed', bottom: 0, right: 0, top: 'unset', left: 'unset' }}
>
{/* card component */}
</Popper>
But this may not be the best solution, maybe you should write the component yourself, because this feature doesn't seem complicated, it may not be necessary to use Popper
.
Just remove anchorEl={anchor}
prop or set it to undefined, popper content will be child of <body>
tag, please double check disablePortal
prop (default is false) (follow official document: https://material-ui.com/api/popper/#props).
Hope this help!
The Popper may appear in the top corer if there is not enough space under the body to draw it. It might be wrapping around and appearing at the top. Try and set your body height to 50% and see if it appears below it.
Using @mui/x-date-pickers": "^6.5.0" In the slotProps add
popper: {
placement: "bottom",
},
版权声明:本文标题:javascript - How do you position Material UI Popper in the bottom right corner of the browser? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738332372a2076278.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论