Html 如何使基础5关帆布导航菜单粘性?
我使用最新版本的基础来添加一个关闭画布导航菜单,并添加一个切换到标签栏。当我使用标签栏时,离开画布菜单的内容会随着页面滚动。如何使菜单内容具有粘性,以便在任何大小的屏幕或页面垂直滚动位置上,点击菜单切换将显示菜单内容而不滚动?到目前为止,我的HTML是:Html 如何使基础5关帆布导航菜单粘性?,html,css,canvas,zurb-foundation,sticky,Html,Css,Canvas,Zurb Foundation,Sticky,我使用最新版本的基础来添加一个关闭画布导航菜单,并添加一个切换到标签栏。当我使用标签栏时,离开画布菜单的内容会随着页面滚动。如何使菜单内容具有粘性,以便在任何大小的屏幕或页面垂直滚动位置上,点击菜单切换将显示菜单内容而不滚动?到目前为止,我的HTML是: <!doctype html> <html class="no-js" lang="en"> <head> <meta charset="utf-8" /> <meta na
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Foundation | Welcome</title>
<link rel="stylesheet" href="css/foundation.css" />
<script src="js/vendor/modernizr.js"></script>
</head>
<body>
<div class="off-canvas-wrap" data-offcanvas>
<div class="contain-to-grid sticky">
<nav class="tab-bar top-bar" data-topbar data-options="sticky_on: large">
<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">Foundation</h1>
</section>
</nav>
</div>
<div class="inner-wrap">
<!-- Off Canvas Menu -->
<aside class="left-off-canvas-menu">
<!-- whatever you want goes here -->
<ul>
<li><a href="#">Item 1</a></li>
<li><a href="#">Item 2</a></li>
<li><a href="#">Item 3</a></li>
<li><a href="#">Item 4</a></li>
<li><a href="#">Item 5</a></li>
</ul>
</aside>
<div class="row">
<div class="large-12 columns">
<h1>Welcome to Foundation</h1>
</div>
</div>
<!-- Content goes here -->
<!-- close the off-canvas menu -->
<a class="exit-off-canvas"></a>
</div>
</div>
<script src="js/vendor/jquery.js"></script>
<script src="js/foundation.min.js"></script>
<script>
$(document).foundation();
</script>
</body>
</html>
基金会欢迎
基础
欢迎来到基金会
$(document.foundation();
将内容的高度设为95vh,溢出y=滚动。每当滚动右侧的内容时,“脱离画布”菜单将不受影响,并保持在顶部
CSS:
.mycontent {
height:95vh;
overflow-y:scroll;
/* fix scrolling on webkit touch devices (iPhone etc) */
-webkit-overflow-scrolling: touch;
}
HTML:
欢迎来到基金会
在css中尝试此功能(100%有效)
我也有同样的问题,打开时无法粘住。最后,我说: CSS:
。选项卡栏{
位置:固定;
z指数:9999;
宽度:100%;
}
在“嘿,看看这里的第一篇文章:如果你想获得与我相同的效果,它似乎工作正常。请记住将你使用的答案标记为已接受。这里有一个很好的链接,链接到vh&vw的浏览器支持,以澄清“mycontent”类“只需浏览页面内容,不包括选项卡栏或画布菜单。这在不添加“粘性”或“固定”类的情况下有效。这也破坏了iPhone上的平滑滚动。滚动变得急促。安卓很好。这个问题是为了让画布外的部分变粘。这只会使选项卡栏变粘。
<div class="row mycontent" >
<div class="large-12 columns">
<h1>Welcome to Foundation</h1>
</div>
</div>
.tab-bar {
position: fixed;
width: 100%;
z-index: 702;
}
.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")
}