1

我正在尝试找到一种方法在响应式引导导航栏的精简视图中包含一些简单的文本内容,但到目前为止没有任何效果。我想要的只是导航栏右上角的一些简单的 [Username] [Log Off],当屏幕太小或调整窗口大小时,它不会赶上其他被制作成可通过按钮访问的列表。我希望登录信息保持在该按钮的右侧,并且在全视图中也与右侧对齐(页面链接向左对齐)。

身体:

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

_登录部分:

@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" })
}

感谢您提前提供任何帮助。我对处理这一切很陌生。

4

1 回答 1

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>
于 2012-10-16T12:21:59.673 回答