我设置了一个贴有导航条的偏移量为100像素(我的标题高度)和引导程序,我修改了.navbar.affix css,给它一个-100px的上边距,以便让它贴在顶部。
嗯,它在PC上完美运行,但是当我在移动设备上预览我的网站时,导航栏很糟糕。
它可以工作,但是当我滚动100px偏移时,它会一直隐藏,直到我抬起手指,然后它出现在顶部。 我没有发布任何代码,因为你必须在移动设备上复制它(复制html,css,js,托管它等),但你知道这是否是一个已知的问题?
如果没问题,否则我做错了
编辑: HTML
<body>
<header class="header">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<center> <h1>My header</h1></center></div>
</div>
</div>
</header>
<nav class="navbar navbar-inverse" data-spy="affix" data-offset-top="100">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.php"></a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="navbar-collapse">
<ul class="nav navbar-nav">
<li ><a href="index.php">Home<span class="sr-only">(current)</span></a></li>
<li class="dropdown active">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown<span class="caret"></span></a>
<ul class="dropdown-menu inverse-dropdown">
<li class="active"><a href="about.php">Su di Noi</a></li>
<li ><a href="#">Element</a></li>
<li><a href="#">Element</a></li>
<li><a href="#">Element</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropwdown<span class="caret"></span></a>
<ul class="dropdown-menu inverse-dropdown">
<li><a href="#">Element</a></li>
<li ><a href="#">Element</a></li>
<li><a href="#">Element</a></li>
<li><a href="#">Element</a></li>
</ul>
</li>
<li><a href="#">Element</a></li>
<li><a href="#">Element</a></li>
</ul>
</div>
</div>
</nav>
<div>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
<h1>TEXT HERE TO ENABLE SCROLLING</h1>
CSS
.header {
height: 100px;
}
.navbar.affix {
width: 100%;
margin-top: -100px;
}
JSFiddle http://jsfiddle.net/Lq94wLbj/