Adding a header image before navbar
How do I add a header image so that it will appear on top of a navbar-fixed-top. And as the user scrolls down the navbar will stick to the top?
I have tried adding it to a container but it does not work as expected.
Here is my code so far.
<body>
<header>
<img src="header/1024x100.png">
</header>
<div class="container-fluid">
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container-fluid">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="#"></a>
<div class="nav-collapse collapse">
<p class="navbar-text pull-right">
Logged in as <a href="#" class="navbar-link">Username</a>
</p>
<ul class="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>
</div>
</div>
Thanks.
JsFiddle with scrolling nav check link
Note: Incase your image is smaller than screen size,insert this snippet inside your css
.masthead img{
width:100%;
}
The html should look like the following :
<div class="masthead">
<img src="http://placehold.it/940x150"/>
</div>
<!-- /container -->
<div class="navbar affix-top" data-spy="affix" data-offset-top="150">
<div class="navbar-inner">
<div class="container">
<ul class="nav">
<li class="active"><a href="#">Home</a>
</li>
<li><a href="#">Link</a>
</li>
<li><a href="#">Link</a>
</li>
</ul>
</div>
</div>
</div>
<!-- navbar -->
<div class="container">
<div class="row-fluid">
<div class="span4">
content goes here
</div>
</div>
</div>
链接地址: http://www.djcxy.com/p/11834.html
上一篇: C#将变量名称转换为字符串
下一篇: 在导航栏前添加标题图片