How to make Foundation 5 off-canvas navigation menu sticky?

旧街凉风 提交于 2019-12-04 04:34:28
Lee Duckworth

Make the height of the content 95vh and the overflow-y=scroll. Whenever the content on the right is scrolled, the off-canvas menu is unaffected and remains at the top.

CSS:

.mycontent {     
  height:95vh;
  overflow-y:scroll;
  /* fix scrolling on webkit touch devices (iPhone etc) */
  -webkit-overflow-scrolling: touch; 
} 

HTML:

  <div class="row mycontent" >
      <div class="large-12 columns">
          <h1>Welcome to Foundation</h1>
      </div>
  </div>

Try this in css (Works 100%)

.tab-bar {
  position: fixed;
  width: 100%;
  z-index: 702;
}

I had the same issue, couldn't get it to stick when open. In the end I went with this:

CSS:

.tab-bar {
position: fixed;
z-index: 9999;
width: 100%;
}

Added an inner wrapper for the off canvas menu right after the "<aside>" tag, before the "off-canvas-list" <ul>s. 
.inner-canvas-menu-wrapper
{ 
position: fixed; 
top: 0; 
overflow-y: hidden; 
width: inherit;
padding-top: 2.8125rem; (standard height of the "tab-bar")
} 

JS

Changed foundation.offcanvas.js -> settings -> open_method to "overlap"

Now it overlaps, but it at least it is fixed/sticky. You may want to change close_on_click to "true" as well in this setup.

If you are using Foundation 6 it will be fixed by default: https://foundation.zurb.com/sites/docs/off-canvas.html#sass-reference

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!