2015-03-02 94 views
-1

我在同一个表格单元格中有两个按钮来编辑和删除用户。现在它正在导致换行而不是在同一行上。我能解决这个问题吗?我的代码是在Rails应用程序的HAML中,我使用的是Twitter Bootstrap。同一行上的HTML单元格中的按钮

用户索引页:

%h1.text-center Users 
%br 
.col-md-6.col-md-offset-3 
    %table.table 
    %th First Name 
    %th Last Name 
    %th E-Mail 
    %th User 
    %th Modify 
    - @users.each do |user| 
     %tr(id="user#{user.id}_row") 
     %td= user.first_name 
     %td= user.last_name 
     %td= user.email 
     %td= user.type 
     %td{ min_width: '100px;'} 
      =edit_user_button(user) + (delete_user_button(user) if is_admin?) 

这里是辅助类生成的按钮:

require 'action_view/helpers/url_helper' 

module UsersHelper 
    def edit_user_button(user) 
    button_to 'edit', edit_user_path(user), class: 'btn btn-default' 
    end 

    def delete_user_button(user) 
    button_to 'delete', destroy_user_path(user), 'method' => :delete, data: {confirm: "Are you sure you want to delete #{user.first_name} #{user.last_name}?"}, class: 'btn btn-default' 
    end 
end 

回答

0

它不换行,表格单元格只是太小,所以作出这样的表格单元更宽。

%td{:min_width => "100px;"} 
+0

嗯,仍然没有运气 - 我只是更新了我的代码,添加了min_width。有任何想法吗? – ThomYorkkke 2015-03-02 22:34:35

+1

我认为@Ixer只是给你一个例子。 100px可能不足以容纳2个按钮,所以如果这是你使用的值,它不会修复它。你是否在浏览器检查器中检查了表格和列的宽度?此外,这可能不太可能,但请检查您的检查器中按钮上的“显示”属性。它们应该设置为“内联”,但是如果CSS中的某个规则将按钮设置为“阻止”,这也会导致它们像这样换行。 – 2015-03-02 23:57:29

相关问题