我正试图找到一种方法,在响应式引导程序导航栏的精简视图中提供一些简单的文本内容,但到目前为止没有任何作用。我想要的只是导航栏右上角的一些简单的[用户名] [注销],当屏幕太小或窗口调整大小时,不会被其他链接所限制。列表可通过按钮访问。我希望登录信息保持在该按钮的右侧,并且在完整视图中也与右侧对齐(页面链接向左对齐)。
体:
<body>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="~/Home/Index">Index</a>
@Html.Partial("_TopMenuPartial")
@Html.Partial("_LoginPartial")
</div>
</div>
</div>
...
</body>
_TopMenuPartial:
<div class="row">
<div class="nav-collapse">
<ul class="nav">
<li class="divider-vertical"></li>
<li class="active"><a href="~/Home/Index">Home</a></li>
<li class="divider-vertical"></li>
<li class="active"><a href="#">Link 2</a></li>
<li class="divider-vertical"></li>
<li class="active"><a href="#">Link 3</a></li>
<li class="divider-vertical"></li>
<li class="active"><a href="#">Link 4</a></li>
</ul>
</div>
</div>
_LoginPartial:
@if (Request.IsAuthenticated)
{
@Html.ActionLink(User.Identity.Name, "Manage", "Account", routeValues: null, htmlAttributes: new { @class = "username", title = "Manage" })
using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm" })) {
@Html.AntiForgeryToken()
<a href="javascript:document.getElementById('logoutForm').submit()">Log off</a>
}
}
else
{
@Html.ActionLink("Register", "Register", "Account", routeValues: null, htmlAttributes: new { id = "registerLink" })
@Html.ActionLink("Log in", "Login", "Account", routeValues: null, htmlAttributes: new { id = "loginLink" })
}
提前感谢您的帮助。我很擅长这一切。
答案 0 :(得分:4)
您需要在可折叠菜单之前放置文本和注销按钮。如果将它放在菜单后面,折叠后它将在新行上。
<html>
<head>
<link href="assets/css/bootstrap.css" rel="stylesheet">
<link href="assets/css/bootstrap-responsive.css" rel="stylesheet">
</head>
<body>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<p class="navbar-text pull-right">
Arnold Daniels
</p>
<a class="brand" href="#">Test</a>
<div class="nav-collapse">
<ul class="nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#">Link 2</a></li>
<li><a href="#">Link 3</a></li>
<li><a href="#">Link 4</a></li>
</ul>
</div>
</div>
</div>
</div>
<script src="assets/js/jquery.js"></script>
<script src="assets/js/bootstrap-collapse.js"></script>
</body>
</html>