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

Sai*_*man 2 html javascript css css-selectors

这是我的应用程序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;
   }
Run Code Online (Sandbox Code Playgroud)

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

滚动前: 滚动前

滚动后: 滚动后

Bre*_*ron 6

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

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

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