简体   繁体   English

JS 叠加菜单未显示

[英]JS Overlay Menu Not Showing

I would like to display this full screen overlay menu (which works great) on my web page, on the top left hand side.我想在我的网页左上角显示这个全屏覆盖菜单(效果很好)。 My code so far can be seen here .到目前为止,我的代码可以在这里看到。

When I click the overlay menu, it seems to be 'hidden' behind the main page content.当我单击覆盖菜单时,它似乎“隐藏”在主页内容的后面。

I changed some of the z-index values for the overlay menu, but when I did this the main page navigation (element called slick-dots ) stopped working (visible but not clickable).我更改了叠加菜单的一些z-index值,但是当我这样做时,主页导航(称为slick-dots元素)停止工作(可见但不可点击)。

When the overlay menu is open, the navigation ( slick-dots ) should be hidden.当覆盖菜单打开时,导航( slick-dots )应该被隐藏。 However when the full screen menu is closed, the navigation should be visible and work.但是,当全屏菜单关闭时,导航应该是可见的并且可以工作。

I'm not sure how I should configure the z-index or position values in order to achieve what I want?我不确定我应该如何配置z-indexposition值才能实现我想要的?

Any help with this would be appreciated.对此的任何帮助将不胜感激。

With the z-index solution you mentioned, you couldn't click your slick-dots nav because when you use visibility: hidden instead of display: none , the element is still there, taking up space on top of everything else, intercepting mouse events.使用您提到的 z-index 解决方案,您无法单击您的圆点导航,因为当您使用visibility: hidden而不是display: none ,元素仍然存在,占用其他所有内容的空间,拦截鼠标事件. You can use pointer-events: none along with visibility to let hovers and clicks fall through it.您可以使用pointer-events: nonevisibility来让悬停和点击穿过它。

.nav {
  visibility: hidden;
  pointer-events: none;
  z-index: 100;
}

body.nav-active .nav {
  visibility: visible;
  pointer-events: auto;
}

Here's a Pen of it working.这是它工作的一支笔。 pointer-events only works in IE11, so if you need to support IE10 you'll have to add some sort of workaround. pointer-events仅适用于 IE11,因此如果您需要支持 IE10,则必须添加某种解决方法。

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

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