我有一个非常简单的Bootstrap Navbar
,我正在尝试进行一些自定义。我想要做的就是将所有左侧的标题拉出来,并将3个选项Home
Menu 1
和Menu 2
拉到一边。我曾尝试将pull-left
和pull-right
添加到我的内联样式中,但相信它已被覆盖了....有人能告诉我如何才能实现这一目标吗?我将在下面发布图片和标记:
图像是我现在拥有的,而不是我想要完成的。标记是我现有的HTML。
标记
<nav class="navbar navbar-inverse" style="margin-bottom: -5px !important;">
<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="#">My Title</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li runat="server" class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Menu 1<b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#"><i class="glyphicon glyphicon-pencil"></i> 3</a></li>
<li class="divider"></li>
<li><a href="#"><i class="glyphicon glyphicon-folder-close"></i> 4</a></li>
<li class="divider"></li>
<li><a href="#"><i class="glyphicon glyphicon-thumbs-up"></i> 5</a></li>
</ul>
</li>
<li runat="server" class="dropdown">
<ul class="dropdown-menu">
<li><a href="#"><i class="glyphicon glyphicon-user"></i> 1</a></li>
<li class="divider"></li>
<li><a href="#" target="_blank"><i class="glyphicon glyphicon-lock"></i> 2</a></li>
<li class="divider"></li>
<li><a href="#"><i class="glyphicon glyphicon-log-out"></i> 3</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
答案 0 :(得分:2)
使用container-fluid
作为您的链接,如果您希望它们在屏幕的左侧和右侧,请使用container
代替<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<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="#">My Title</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li class="active"><a href="#">Home</a>
</li>
<li runat="server" class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Menu 1<b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#"><i class="glyphicon glyphicon-pencil"></i> 3</a>
</li>
<li class="divider"></li>
<li><a href="#"><i class="glyphicon glyphicon-folder-close"></i> 4</a>
</li>
<li class="divider"></li>
<li><a href="#"><i class="glyphicon glyphicon-thumbs-up"></i> 5</a>
</li>
</ul>
</li>
<li runat="server" class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Menu 2<b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#"><i class="glyphicon glyphicon-user"></i> 1</a>
</li>
<li class="divider"></li>
<li><a href="#" target="_blank"><i class="glyphicon glyphicon-lock"></i> 2</a>
</li>
<li class="divider"></li>
<li><a href="#"><i class="glyphicon glyphicon-log-out"></i> 3</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
。
请参阅示例代码段。
{{1}}