2012-08-16 63 views
1

我的源代碼看起來是這樣的如何使登錄/註冊向上按鈕浮動權自舉

<div class="navbar"> 
    <div class="navbar-inner"> 
    <div class="container"> 
     <ul class="nav"> 
     <a class="brand" href="#">Project name</a> 

     <li><%= link_to 'Home', pages_home_path %></li> 

     <li><%= link_to 'About', pages_about_path %></li> 

     <li><%= link_to 'Contact Us', pages_contact_path %></li> 




     <li class="nav pull-right"> 
      <div id="user_nav"> 
      <% if user_signed_in? %> 
      Signed in as <%= current_user.email %>. Not you? 
      <%= link_to "Sign out", destroy_user_session_path, :method => :delete, :class => 'btn btn-danger btn-mini' %> 
      <% else %> 
      <%= link_to new_user_registration_path do %> 
      <button class="btn-mini btn btn-info">Sign Up</button> 
      <% end %> 
      or <%= link_to new_user_session_path do %> 
      <button class="btn btn-info btn-mini">Sign In</button> 
      <% end %> 
      <% end %> 
      </div> 
     </li> 

     </ul> 
    </div> 
    </div> 
</div> 

我使用.pull-right在我的用戶登錄/退出部分,但它只是你可以在twitter-bootstrap原始頁面中看到右移一點,但不會移到極右。請讓我知道我做錯了什麼。

回答

2

試試這個方法:

<div class="navbar"> 
    <div class="navbar-inner"> 
    <div class="container"> 
     <ul class="nav"> 
     <a class="brand" href="#">Project name</a> 

     <li><%= link_to 'Home', pages_home_path %></li> 

     <li><%= link_to 'About', pages_about_path %></li> 

     <li><%= link_to 'Contact Us', pages_contact_path %></li> 
     </ul> 



     <ul class="nav pull-right"> 
     <li> 
      <div id="user_nav"> 
      <% if user_signed_in? %> 
      Signed in as <%= current_user.email %>. Not you? 
      <%= link_to "Sign out", destroy_user_session_path, :method => :delete, :class => 'btn btn-danger btn-mini' %> 
      <% else %> 
      <%= link_to new_user_registration_path do %> 
      <button class="btn-mini btn btn-info">Sign Up</button> 
      <% end %> 
      or <%= link_to new_user_session_path do %> 
      <button class="btn btn-info btn-mini">Sign In</button> 
      <% end %> 
      <% end %> 
      </div> 
     </li> 
     </ul> 

    </div> 
    </div> 
</div> 
+0

真棒!作品!非常感謝......:D。 – Clone 2012-08-16 20:21:17

+0

;)不客氣! – Michael 2012-08-16 20:22:42

+1

我甚至高呼:D heheh! – Clone 2012-08-16 20:23:38