Logo Centered Inside Navbar 我尝试使用bootstrap实现它.. 但是我不想折叠徽标部分,只能折叠其他李。
<header role="banner">
<nav id="navbar-primary" class="navbar" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-primary-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse" id="navbar-primary-collapse">
<ul class="nav navbar-nav">
<li><a href="#"><span class="glyphicon glyphicon-home"
aria-hidden="true"></span> Home</a></li>
<li style="margin-right: 80px"><a href="articles.html"><i class="fa fa-pagelines" aria-hidden="true"></i>
Articles</a></li>
<li style="margin-left: 80px"><a href="signIn.html"><i class="fa fa-sign-in" aria-hidden="true"></i>
Sign in</a></li>
<li class="active"><a href="signUp.html"><i class="fa fa-sign-in" aria-hidden="true"></i>
Sign up</a></li>
</ul>
</div>
<div style="float:none">
<a href="#"><img src="../image/uoblogo.png" height="60px" width="200px" ></a>
</div>
</div>
</nav>
</header>
答案 0 :(得分:1)
这基本上是answered on SO before。您需要根据图片高度调整CSS等,并将navbar-brand
保留在navbar-collapse
.navbar-brand {
position: absolute;
width: 100%;
left: 0;
top: 0;
text-align: center;
margin: auto;
}
.navbar-brand > img {
display: initial;
}
.navbar-toggle {
z-index:3;
}
答案 1 :(得分:0)
在ul中移动图片并对每个li应用vertical-align将解决您的问题
检查此codepen
将您的商标更改为以下
<header role="banner">
<nav id="navbar-primary" class="navbar" role="navigation">
<ul class="nav navbar-nav">
<li>
<a href="#">
<span class="glyphicon glyphicon-home icon" aria-hidden="true"></span> Home</a>
</li>
<li>
<a href="articles.html"><i class="fa fa-pagelines icon" aria-hidden="true"></i>Articles</a>
</li>
<li>
<a href="signIn.html"><i class="icon fa fa-sign-in" aria-hidden="true"></i>Sign in</a>
</li>
<li class="img">
<a href="#"><img src="https://lh6.googleusercontent.com/-lLR_c-yGAKc/AAAAAAAAAAI/AAAAAAAAGoY/3TnWGhgp4-0/s0-c-k-no-ns/photo.jpg" height="60px" width="200px"></a>
</li>
<li class="active">
<a href="signUp.html"><i class="icon fa fa-sign-in" aria-hidden="true"></i>Sign up</a>
</li>
</ul>
</nav>
</header>
和css到以下
ul li a{
line-height:50px!important;
vertical-align:bottom;
}
希望有所帮助