简体   繁体   English

使用Zurb Foundation修复画布外菜单

[英]Fixed Off-Canvas Menu with Zurb Foundation

I am building a web page with Zurb Foundation. 我正在用Zurb Foundation建立一个网页。 I need my web page to run on phones and laptops. 我需要我的网页才能在手机和笔记本电脑上运行。 What's unique about my app is I want to do something more refined than responsive design. 我的应用程序的独特之处在于,我想做比响应式设计更精致的事情。 For that reason, I'm making heavy use of the show-for-small-only and show-for-medium-up classes. 因此,我大量使用了show-for-small-onlyshow-for-medium-up类。

In my phone view, I'm making use of Offcanvas navigation . 在我的电话视图中,我正在使用Offcanvas导航 As the HTML is setup, it works great if you include the content of your page in the off-canvas-wrap div. 设置HTML后,如果将页面内容包含在off-canvas-wrap div中,则效果很好。 However, in my scenario, I cannot do that. 但是,在我的情况下,我无法做到这一点。 Instead, I want to have the content of my page outside of the off-canvas-wrap div. 相反,我希望将页面的内容放置在“ canvas-wrap-div”之外。 This creates two problems: 这产生了两个问题:

  1. The menu doesn't grow to the size of the window. 菜单不会增长到窗口的大小。
  2. If I make the right-off-canvas-menu the height of the window, it pushes my content down. 如果我将右边的画布菜单设置为窗口的高度,则会将我的内容下移。

I've created a JSFiddle here that demonstrates the problem. 我在这里创建了一个演示问题的JSFiddle Is there a way I can make the offcanvas menu just slide over the top of everything? 有没有一种方法可以使offcanvas菜单仅滑过所有内容的顶部? I do not need to push everything to the left. 我不需要将所有内容都推到左边。 Pushing is fine. 推是好的。 My main issue is I need to have the content where it is, but still have the menu appear full-size when needed. 我的主要问题是我需要保留内容所在的位置,但在需要时菜单仍要以全尺寸显示。

Thank you 谢谢

Or if you want to actually use the offcanvas menu and simply have it overlap your content, you can add this CSS (Foundation 5) 或者,如果您想实际使用offcanvas菜单并使它与内容重叠,则可以添加此CSS(基础5)

.off-canvas-wrap.move-right,
.off-canvas-wrap.move-left,
.off-canvas-wrap.move-right .inner-wrap,
.off-canvas-wrap.move-left .inner-wrap {
    height:100%;   
}

.off-canvas-wrap {
    position: absolute;
    z-index:100;
}

.main-content-wrapper {
    padding-top: 2.8125rem;
}

And wrap your content in 并将您的内容包装在

<div class="main-content-wrapper">
    [your page content here]
</div>

I updated your fiddle with the changes so you can see it in action. 我通过更改来更新您的小提琴 ,以便您可以实际操作。 Obviously if you want to only show the offcanvas menu conditionally, you'll want to add a media query wrapper to those rules so they only affect the page when you want them to. 显然,如果您只想有条件地显示offcanvas菜单,则需要向这些规则添加媒体查询包装,以便它们仅在需要时才影响页面。 Otherwise you're adding padding to the top when you don't need it. 否则,您会在不需要时在顶部添加填充。

If you don't want your content to move when you click the navigation button, then you should not use off navigation canvas (that's what its supposed to do). 如果您不希望在单击导航按钮时移动内容,则不应使用非导航画布(这是应该做的事情)。 Instead just use the Foundation 5 Button and set the CSS to be height = 100% 相反,只需使用Foundation 5 Button并将CSS设置为height = 100%

http://foundation.zurb.com/docs/components/dropdown.html http://foundation.zurb.com/docs/components/dropdown.html

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

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