我正在使用Bootstrap 3,并且已经修复了标题导航栏。我左边有几个菜单项,右边有三个菜单项。类似于Stackoverflow(减去搜索栏)。
当我缩小浏览器窗口时 - 右侧菜单项位于左侧菜单项下方,直到最终提供切换开关。
如何解决此问题,以便它不会移动左侧项目下方的右侧菜单项?
body {
min-height: 70px;
padding-top: 70px;
}

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<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="/"><span class="som-brand-color">Brand Title</span></a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="/">Home</a></li>
<li><a href="/">Dashboard</a></li>
<li><a href="/">My Account</a></li>
<li><a href="/">Reporting Tools</a></li>
<li><a href="/">Alerts & Notifications</a></li>
<li><a href="/">Release Notes</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="/alerts/"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> Item 1</a></li>
<li><a href="/settings/"><i class="fa fa-cogs" aria-hidden="true"></i> Item 2</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><i class="fa fa-user" aria-hidden="true"></i> Item 3<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href=""><i class="fa fa-pencil-square-o" aria-hidden="true"></i> Sub-item 1</a></li>
<li><a href=""><i class="fa fa-sign-out" aria-hidden="true"></i> Sub-item 2</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
&#13;
答案 0 :(得分:1)
您需要使用媒体查询..如果您有许多菜单项需要根据屏幕尺寸更改字体大小和边距。
我提供了一个只有字体大小更改的解决方案 您可以修改大量参数以优化字体大小填充和所有内容。
示例摘录
body {
min-height: 70px;
padding-top: 70px;
}
@media (min-width: 767px) and (max-width: 1200px) {
.navbar-nav > li > a {
font-size:8px;
padding-left: 5px;
padding-right: 5px;
}
.navbar-brand {
font-size: 15px;
}
}
&#13;
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<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="/"><span class="som-brand-color">Brand Title</span></a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="/">Home</a></li>
<li><a href="/">Dashboard</a></li>
<li><a href="/">My Account</a></li>
<li><a href="/">Reporting Tools</a></li>
<li><a href="/">Alerts & Notifications</a></li>
<li><a href="/">Release Notes</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="/alerts/"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> Item 1</a></li>
<li><a href="/settings/"><i class="fa fa-cogs" aria-hidden="true"></i> Item 2</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><i class="fa fa-user" aria-hidden="true"></i> Item 3<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href=""><i class="fa fa-pencil-square-o" aria-hidden="true"></i> Sub-item 1</a></li>
<li><a href=""><i class="fa fa-sign-out" aria-hidden="true"></i> Sub-item 2</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
&#13;
注意:对于导航栏结帐的早期崩溃这些答案 -