admin管理员组文章数量:1328398
I'm starting with Foundation and trying to get an off canvas example working. I've been struggling because the menu opens and closes like it should, however if the page content is long and you scroll toward the bottom, when you open the menu, the focus is where you are on the page. IE, the fixed toolbar and menu aren't fixed when open.
I've done an example on a fiddle, and would love some help!
JSFiddle Example
HTML
<div class="off-canvas-wrap" data-offcanvas="">
<div class="inner-wrap">
<div class="fixed">
<nav class="tab-bar">
<section class="left-small">
<a class="left-off-canvas-toggle menu-icon" href="#"><span></span></a>
</section>
<section class="middle tab-bar-section">
<h1 class="title">Forest School - PARS Insight</h1>
</section>
</nav>
</div>
<aside class="left-off-canvas-menu">
<ul class="off-canvas-list">
<li><label>General</label></li>
<li><a href="#">Snapshot</a></li>
<li><a href="#">Timetable</a></li>
<li><a href="#">Homework</a></li>
</ul>
</aside>
Long Body Content Here
CSS
.off-canvas-wrap, .inner-wrap {
min-height: 100%;
}
.off-canvas-wrap{
height: 100%;
overflow-y: auto;
}
Javascript
$(document).foundation();
I'm starting with Foundation and trying to get an off canvas example working. I've been struggling because the menu opens and closes like it should, however if the page content is long and you scroll toward the bottom, when you open the menu, the focus is where you are on the page. IE, the fixed toolbar and menu aren't fixed when open.
I've done an example on a fiddle, and would love some help!
JSFiddle Example
HTML
<div class="off-canvas-wrap" data-offcanvas="">
<div class="inner-wrap">
<div class="fixed">
<nav class="tab-bar">
<section class="left-small">
<a class="left-off-canvas-toggle menu-icon" href="#"><span></span></a>
</section>
<section class="middle tab-bar-section">
<h1 class="title">Forest School - PARS Insight</h1>
</section>
</nav>
</div>
<aside class="left-off-canvas-menu">
<ul class="off-canvas-list">
<li><label>General</label></li>
<li><a href="#">Snapshot</a></li>
<li><a href="#">Timetable</a></li>
<li><a href="#">Homework</a></li>
</ul>
</aside>
Long Body Content Here
CSS
.off-canvas-wrap, .inner-wrap {
min-height: 100%;
}
.off-canvas-wrap{
height: 100%;
overflow-y: auto;
}
Javascript
$(document).foundation();
Share
Improve this question
edited Jan 26, 2015 at 12:55
Knut Holm
4,1624 gold badges35 silver badges55 bronze badges
asked Jan 23, 2015 at 15:12
CaseyCasey
1841 gold badge3 silver badges10 bronze badges
2 Answers
Reset to default 7This is very popular Foundation issue:
http://foundation.zurb./forum/posts/965-fixed-menu-using-offcanvas
http://foundation.zurb./forum/posts/547-off-canvas-with-fixed-top-bar
https://github./zurb/foundation/issues/3863
https://github./zurb/foundation/issues/3710
Despite of it seems that official solution doesn's exist yet I have found this one (reference) which looks like a nice fix of your problem.
HTML
<div class="off-canvas-wrap">
<div class="inner-wrap">
<div class="header">
<nav class="tab-bar" data-offcanvas>
<section class="left-small">
<a class="left-off-canvas-toggle menu-icon">
<span></span>
</a>
</section>
<section class="right tab-bar-section">
<h1>Foundation 5 test</h1>
</section>
</nav>
</div>
<aside class="left-off-canvas-menu">
<ul class="off-canvas-list">
<li>
<label>Foundation</label>
</li>
[...]
<li><a href="#">The Psychohistorians</a>
[...]
</li>
</ul>
</aside>
<article class="small-12 columns">
<p>Content</p>
<p>Content</p>
<div data-magellan-expedition="fixed">
<dl class="sub-nav panel">
<dd data-magellan-arrival="build">
<a href="#build">Build with HTML</a>
</dd>
<dd data-magellan-arrival="js">
<a href="#js">Arrival 2</a>
</dd>
</dl>
</div>
[...]
<p>Content</p>
[...]
</article>
<a class="exit-off-canvas"></a>
<footer class="small-12 columns">
<div>...</div>
</footer>
</div>
</div>
CSS
article {
overflow-y: auto;
}
article,
body,
html,
.off-canvas-wrap,
.off-canvas-wrap .inner-wrap,
.row {
height: 100%;
width: 100%;
}
.header {
position: absolute;
top: 0;
width: 100%;
z-index: 99;
}
I dont have enough reputation to ment..so ill add on as an answer to Akarienta's.
I had scrolling problem on mobile browsers with the solution above.
I added -webkit-overflow-scrolling: touch
for the scrolling to work
article,
.off-canvas-wrap,
.off-canvas-wrap .inner-wrap
height: 100%
width: 100%
-webkit-overflow-scrolling: touch
article
overflow-y: auto
thanks to this question
本文标签: javascriptFoundationOff Canvas Scroll IssueStack Overflow
版权声明:本文标题:javascript - Foundation - Off Canvas Scroll Issue - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742234669a2437856.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论