Bootstrap 3:如何在100%高度后粘贴 [英] Bootstrap 3: How to affix after 100% height
本文介绍了Bootstrap 3:如何在100%高度后粘贴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在尝试将简介设置为100%高度后,我试图将导航栏粘贴到顶部,但是我不确定执行此操作的最佳方法是什么?
I am trying to get my navbar to affix to the top after an intro that is set at 100% height but I am unsure what is the best way to go about doing this?
代码:
CSS
html, body{ height: 100%; min-height: 100%;}
.intro {height: 100%;text-align: center;}
HTML
<div class="intro">
<div class="container">
<h1>Lorem Ipsum</h1>
</div>
</div>
<nav>
<div class="container">
<div class="navbar-header" data-spy="affix">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<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="#">Test Navbar</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
我正在使用Bootstrap 3.0.
I am using Bootstrap 3.0.
推荐答案
您可以使用jQuery函数计算#intro
You can use a jQuery function to calc the height of the #intro
$('nav').affix({
offset: {
top: $('.intro').height()
}
});
这是一个以类似方式工作的演示..
Here's a demo that works in a similar way..
这篇关于Bootstrap 3:如何在100%高度后粘贴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文