gpt4 book ai didi

javascript - 当我在 chrome mobile 中向下滚动时,绝对定位的 DIV 会改变位置,如何解决这个问题?

转载 作者:太空宇宙 更新时间:2023-11-03 21:03:24 25 4
gpt4 key购买 nike

这是我的应用 https://scisaif.github.io/Budget-App/

div 元素的 CSS:

.add-box, .add-box-opt {
position: absolute;
bottom: 0vh;
right: 0vw;
width: 100px;
min-height: 100px;
border-top: 2px solid white;
border-left: 2px solid white;
border-radius: 80% 0 0 0 ;
box-shadow: -1px -1px 10px rgba(211, 209, 209, 0.562);
cursor: crosshair;
}

我希望 div 框保持在右下角,即使我滚动,这个问题只发生在移动版的 chrome 浏览器中。请帮忙。

滚动前: before scroll

滚动后: after scroll

最佳答案

您的问题应该通过使用 position: fixed 而不是 position: absolute 来解决。

这是因为 position: fixed 是相对于视口(viewport)的,而 position: absolute 是相对于最近定位的祖先

确保保留 bottom: 0;right: 0;

关于javascript - 当我在 chrome mobile 中向下滚动时,绝对定位的 DIV 会改变位置,如何解决这个问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57054206/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com