gpt4 book ai didi

html - Bootstrap 导航栏定制

转载 作者:太空宇宙 更新时间:2023-11-04 02:48:50 24 4
gpt4 key购买 nike

我有一个非常简单的 Bootstrap Navbar,我正在尝试对其进行一些自定义。我想要做的就是将标题拉到最左边,将 3 个选项 Home Menu 1Menu 2 拉到所有方式正确。我试图将 pull-leftpull-right 添加到我的内联样式中,但相信它被覆盖了....谁能告诉我如何完成这?我将在下面发布图片和标记:

图像是我目前拥有的,而不是我想要完成的。标记是我现有的 HTML。

enter image description here

标记

<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>

最佳答案

使用 navbar-right 作为您的链接,如果您希望它们在屏幕的左侧和右侧尽可能远,请使用 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>

关于html - Bootstrap 导航栏定制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33381459/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com