Search code examples
twitter-bootstraptwitterheadercentering

Twitter Bootstrap Column Headers won't center


<table class="table table-striped table-bordered">
  <thead>
    <tr>
      <th><%= model_class.human_attribute_name(:id) %></th>
      <th><%= model_class.human_attribute_name(:projectid) %></th>
      <th><%= model_class.human_attribute_name(:ppiho) %></th>
      <th><%= model_class.human_attribute_name(:needby) %></th>
      <th><%= model_class.human_attribute_name(:quantity) %></th>
      <th><%= model_class.human_attribute_name(:model) %></th>
      <th><%= model_class.human_attribute_name(:prnum) %></th>
      <th><%= model_class.human_attribute_name(:ponum) %></th>
      <th><%= model_class.human_attribute_name(:status) %></th>
      <th><%= model_class.human_attribute_name(:contact) %></th>
      <th><%= model_class.human_attribute_name(:notes) %></th>
      <th><%= model_class.human_attribute_name(:created_at) %></th>
      <th><%=t '.actions', :default => t("helpers.actions") %></th>
    </tr>
  </thead>
  <tbody>
    <% @orders.each do |order| %>
      <tr>
        <td align="center"><%= link_to order.id, order_path(order) %></td>
        <td align="center"><%= order.projectid %></td>
        <td align="center"><%= order.ppiho %></td>
        <td align="center"><%= order.needby %></td>
        <td align="center"><%= order.quantity %></td>
        <td align="center"><%= order.model %></td>
        <td align="center"><%= order.prnum %></td>
        <td align="center"><%= order.ponum %></td>
        <td align="center"><%= order.status %></td>
        <td align="center"><%= order.contact %></td>
        <td align="center"><%= order.notes %></td>
        <td align="center"><%=l order.created_at %></td>
        <td>
          <%= link_to t('.edit', :default => t("helpers.links.edit")),
                      edit_order_path(order), :class => 'btn btn-default btn-xs' %>
          <%= link_to t('.destroy', :default => t("helpers.links.destroy")),
                      order_path(order),
                      :method => :delete,
                      :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) },
                      :class => 'btn btn-xs btn-danger' %>
        </td>
      </tr>
    <% end %>
  </tbody>
</table>

While I can get the actual table data to center, it refuses no matter what I try to center the headers. I need to get these things centered. If anyone has any ideas I'd appreciate it.

If I can get them to center I can move on to trying to get the header frozen.


Solution

  • I have solved this; I was being dense. You can use the same css to align the th as td I found in another post >.<

    .table td {
       text-align: center;   
    }
    

    works with th too.

    .table th {
       text-align: center;   
    }