简体   繁体   English

窗口顶部的固定菜单问题

[英]Issue with fixed menu at top of window

I have a menu that is added to the top of the page when a user selects an element on screen.当用户在屏幕上选择一个元素时,我有一个菜单被添加到页面顶部。

I have given it a higher z-index , but it still causes the page to scroll down a bit when an element is clicked.我给了它一个更高的z-index ,但是当点击一个元素时它仍然会导致页面向下滚动一点。

Any ideas as to how to get around this?关于如何解决这个问题的任何想法?

Managed to fix the issue.设法解决了这个问题。

Because the element was being repositioned, it was being taken out of the document flow.因为元素被重新定位,它被从文档流中取出。 This caused the page to jump upwards whenever this happened.这会导致页面在发生这种情况时向上跳。

I fixed it by adding a container element with the same height as the element that is moved so now the jump does not happen because there is an element taking up the space vacated by the moved item.我通过添加一个与被移动元素高度相同的容器元素来修复它,所以现在不会发生跳转,因为有一个元素占用了被移动项目腾出的空间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM