无法使用class = pull-right或float:right浮动twitter bootstrap导航栏项目

Per*_*ich 12 css formatting firebug ruby-on-rails twitter-bootstrap

我正在使用Twitter引导程序和Rails,我似乎无法将导航栏项目浮动到右侧.

我试过用这样的东西:

<li class="whoami pull-right"> <%= link_to ("Logged in as: " + current_user.name), edit_user_registration_path , :id=>"Edit account"%> </li>
Run Code Online (Sandbox Code Playgroud)

......但是链接保持不变,萤火虫显示出来了 "float:left;"

所以我试图将css浮在里面bootstrap_and_overrides.css.less和里面home.html.erb,但都没有奏效.Firebug表示它发现了两个css float语句,但选择了bootstrap选项.所以我被困住了,想知道如何自定义导航栏.我可能在这里做错了,但我只是没有看到它.

这是我的代码:

application.html.erb:

<!DOCTYPE html>
<html>
  <head>
  ... removed to shorten the length of this post
  </head>
  <body>
    <header>
          <%= render 'layouts/navigation' %>
    </header>
    <div id="main" role="main">
      <div class="container">
        <div class="content">
           <div class="row">
            <div class="span12">
              <%= render 'layouts/messages' %>
              <%= yield %>
            </div>
          </div>
          <footer>
          </footer>
        </div>
      </div> <!--! end of .container -->
    </div> <!--! end of #main -->
  </body>
</html> 
Run Code Online (Sandbox Code Playgroud)

_navigation.html.erb:

<div class="container span12">
  <div class="navbar navbar-fixed-top">
    <div class="navbar-inner">
      <div class="container">
        <ul class="nav">
        <%= link_to "Cases", root_path, :class=>"brand"%>
          <% if user_signed_in? %>
              <li> <%= link_to "My Cases", cases_path %> </li> 
              <li> <%= link_to 'Dash', dash_path %> </li> 
            <% if current_user.has_role? :admin %>
              <li> <%= link_to 'Admin', users_path, :id=>"Admin" %> </li>
            <% end %>
            <li> <%= link_to 'Logout', destroy_user_session_path, :method=>'delete', :id => "Logout" %> </li>
            <li class="whoami"> <%= link_to ("Logged in as: " + current_user.name), edit_user_registration_path , :id=>"Edit account"%> </li>
          <% else %>
              <li> <%= link_to 'Login', new_user_session_path %> </li>
              <li> <%= link_to 'Sign up', new_user_registration_path %> </li>
          <% end %>
        </ul>
      </div>
    </div>
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

bootstrap_and_overrides.css.less:

@import "twitter/bootstrap/bootstrap";
body { 
    padding-top: 60px;
}
@import "twitter/bootstrap/responsive";

// Set the correct sprite paths
// ...REMOVED to shorten the length of this post
// Your custom LESS stylesheets goes here
//
// Since bootstrap was imported above you have access to its mixins which
// you may use and inherit here
//
// If you'd like to override bootstrap's own variables, you can do so here as well
// See http://twitter.github.com/bootstrap/less.html for their names and documentation
//
// Example:
// @linkColor: #ff0000;

.whoami {
    float:right;
}
Run Code Online (Sandbox Code Playgroud)

当我加载页面时,我看到导航栏,但最后一项没有浮动到右侧.

看起来像这样:
屏幕截图显示萤火虫信息

此处还有另一个屏幕截图,显示了更多信息.

如您所见,firebug找到了一个"float:right;"选项,但表示使用了一个"float:left;"选项.

我在这里理解上有差距,但我不知道在哪里.

请回复:

  • 使用pull-right和twitter bootstrap导航栏格式
  • 压倒css
  • 解释萤火虫输出

    编辑:我在这里发布了我的第一个jsfiddle:http://jsfiddle.net/uCHQs/2/ 它表示浏览器'show source'的复制/粘贴,我收集的是相关的css加载并由rails提供服务.

提前致谢!

Per*_*ich 21

得到它了.

让它工作需要填充嵌套在navbar-inner中的容器,其中包含多个无序的nav元素列表.这个jsfiddle向我展示了http://jsfiddle.net/N6vGZ/4/的方式

此代码有效:

<div class="container span12">
  <div class="navbar navbar-fixed-top">
    <div class="navbar-inner">
      <div class="container">
        <%= link_to "Cases", root_path, :class=>"brand"%>
          <ul class="nav">
          <% if user_signed_in? %>
              <li> <%= link_to "My Cases", cases_path %> </li> 
              <li> <%= link_to 'Dash', dash_path %> </li> 
            <% if current_user.has_role? :admin %>
              <li> <%= link_to 'Admin', users_path, :id=>"Admin" %> </li>
            <% end %>
            <li> <%= link_to 'Logout', destroy_user_session_path, :method=>'delete', :id => "Logout" %> </li>
          </ul>
           <ul class="nav pull-right"> <li> <%= link_to ("Logged in as: " + current_user.name), edit_user_registration_path , :id=>"Edit account"%> </li></ul>
          <% else %>
            <ul class="nav">
              <li> <%= link_to 'Login', new_user_session_path %> </li>
              <li> <%= link_to 'Sign up', new_user_registration_path %> </li>
            </ul>
          <% end %>
        </ul>
      </div>
    </div>
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)