【发布时间】:2017-09-12 10:46:52
【问题描述】:
我的页面中有一个固定的顶部导航栏,导航栏设置为具有固定高度的图像,并且导航栏本身有一个高度,我想要做的是将导航栏品牌徽标与列表上的列表垂直对齐大屏幕和响应式屏幕的右侧,我该怎么做? 这是我的代码:
.navbar{
height:150px;
}
.navbar-brand img{
height:95px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<html>
<body><!-- Navigation -->
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<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="#">
<img src="http://placehold.it/150x50&text=Logo" alt="">
</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li>
<a href="#">About</a>
</li>
<li>
<a href="#">Services</a>
</li>
<li>
<a href="#">Contact</a>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</body>
</html>
【问题讨论】:
-
您希望徽标在移动视图中位于导航栏下方吗?
-
@DanielH 不,我希望它们彼此相邻
-
欢迎来到stackOverflow @Heba,如果任何答案对您有帮助vote it up,如果答案是您正在寻找的答案,请将其标记为Correct answe,以供未来的读者使用。谢谢!
标签: html css twitter-bootstrap navbar