我无法让导航栏停留在窗口顶部。我试过使用“粘性数据”,但没有。无论我做什么,它都会随着页面滚动。我还尝试将类添加到中小型导航中。有什么建议么?
html:
<!-- Small Navigation -->
<div class="title-bar" data-responsive-toggle="nav-menu" data-hide-for="medium">
<a class="logo-small show-for-small-only" href="#"><img src="/assets/img/fingerLogoXS.gif" /></a>
<button class="menu-icon" type="button" data-toggle></button>
<div class="title-bar-title">Menu</div>
</div>
<!-- Medium-Up Navigation -->
<nav class="top-bar" id="nav-menu">
<div class="logo-wrapper hide-for-small-only">
<div class="logo">
<img src="/assets/img/fingerLogoSM.2.gif">
</div>
</div>
<!-- Left Nav Section -->
<div class="top-bar-left">
<ul class="vertical medium-horizontal menu">
<li><a href="#">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
<!-- Right Nav Section -->
<div class="top-bar-right">
<ul class="vertical medium-horizontal dropdown menu" data-dropdown-menu>
<li class="has-submenu">
<a href="#">Technologies</a>
<ul class="submenu menu vertical medium-horizontal" data-submenu>
<li><a href="#">Foundation</a></li>
<li><a href="#">HTML5</a></li>
<li><a href="#">CSS3</a></li>
<li><a href="#">JavaScript</a></li>
</ul>
</li>
<li>
<a href="#">Portfolio</a>
</li>
</ul>
</div>
</nav>
<!--End Main Navigation-->
CSS:
/* Small Navigation */
.logo-small {
float: right;
padding: 4px;
}
.title-bar {
padding: 0 .5rem;
background-color: #3D3242;
}
.menu-icon,
.title-bar-title {
position: relative;
top: 10px;
padding: 4px;
}
/* Medium-Up Navigation */
@media only screen and (min-width: 40rem) {
.sticky {
width: 100%;
}
.logo-wrapper {
position: relative;
}
.logo-wrapper .logo {
width: 92px;
height: 92px;
position: absolute;
left: 50%;
right: 50%;
top: -6px;
margin-left: -46px;
}
// Right part
.top-bar-right {
width: 50%;
padding-left: 60px;
}
.top-bar-right ul {
float: left;
}
// Left part
.top-bar-left {
width: 50%;
padding-right: 60px;
}
.top-bar-left ul {
float: right;
}
}