简体   繁体   English

Foundation 6 画布外菜单不会“隐藏”可见页面

[英]Foundation 6 off-canvas-menu doesn't "hide" visible page

I'm building an off-canvas-menu for small viewports with Foundation 6 and i can't get to overlap the whole visible page area .我正在为 Foundation 6 的小视口构建一个画布外菜单,但我无法重叠整个可见页面区域。 The area right hand side underneath of the off-canvas-menu doesn't have background opacity.画布菜单下方的右侧区域没有背景不透明度。

在此处输入图片说明

To try it just resize the browser viewport width less than 640px (small viewport) and click on the burger icon on the top left.要尝试它,只需将浏览器视口宽度调整为小于 640 像素(小视口),然后单击左上角的汉堡图标。

link to website网站链接

How can i ink the whole with transparent black color instead just the upper part?我怎样才能用透明的黑色来墨水整个而不是上半部分?

I think this is by design, but kinda buggy.我认为这是设计使然,但有点马车。

That grey overlay's parent takes up 100% of the screen height when the off-canvas menu is opened, and you typically don't see anything beneath it to notice that it doesn't cover all the content because that content is out of the viewport.当关闭画布菜单时,灰色覆盖的父级占据屏幕高度的 100%,并且您通常看不到它下方的任何内容以注意到它没有覆盖所有内容,因为该内容超出了视口.

You can set the height on that wrapper to 'auto' or remove the 100% value for height altogether.您可以将该包装器上的高度设置为“自动”或完全删除高度的 100% 值。 The caveat to this is that when you do this, ALL the content in the viewport is going to scroll, not just what is inside the off-canvas menu.需要注意的是,当您执行此操作时,视口中的所有内容都将滚动,而不仅仅是画布菜单中的内容。

// This element needs to have the height override
<div class="off-canvas-wrapper-inner is-off-canvas-open is-open-left" data-off-canvas-wrapper="">...</div>

.off-canvas-wrapper, .off-canvas-wrapper-inner {
    height: 100% <-- remove this, override it, or set to 'auto'.
}

With Javascript, you can listen for opened.zf.offcanvas event and manually add the grey overlay to the tag that has the off-canvas-content class.使用 Javascript,您可以监听opened.zf.offcanvas事件并手动将灰色覆盖添加到具有off-canvas-content类的标签。 Conversely, listen for closed.zf.offcanvas event and remove the css you added when it fires.相反,监听closed.zf.offcanvas事件并在它触发时删除您添加的 css。

Using the example code from Foundation docs:使用 Foundation 文档中的示例代码:

With HTML:使用 HTML:

        <!-- Close button -->
        <button class="close-button" aria-label="Close menu" type="button" data-close>
          <span aria-hidden="true">&times;</span>
        </button>

        <!-- Menu -->
        <ul class="vertical menu">
          <li><a href="#">Foundation</a></li>
          <li><a href="#">Dot</a></li>
          <li><a href="#">ZURB</a></li>
          <li><a href="#">Com</a></li>
          <li><a href="#">Slash</a></li>
          <li><a href="#">Sites</a></li>
        </ul>

      </div>

      <div class="off-canvas-content" data-off-canvas-content>
        <!-- Page content -->
      </div>
    </div>
  </div>
</body>

Then:然后:

$('.off-canvas-wrapper').on('opened.zf.offcanvas', function() {
  $('.off-canvas-content').addClass('grey-out');
});
$('.off-canvas-wrapper').on('closed.zf.offcanvas', function() {
  $('.off-canvas-content').removeClass('grey-out');
});

grey-out class: grey-out类:

.grey-out {
  background: rgba(60,60,60,0.75) !important;
  z-index: 1000;
}

I didn't test this but you get the idea.我没有测试这个,但你明白了。

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

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