chris Frisina
chris Frisina

Reputation: 19688

Merged Table Headers in Haml

I am trying to accomplish this in haml:enter image description here

How do I adjust the following to have merged cell headers to accomplish the same as the excel picture:

%table
  %tbody
    %tr
      %th Name
      %th Sunday      
      %th Monday
      %th Tuesday
      %th Wednesday
      %th Thursday
      %th Friday
      %th Saturday
    %tr
      %th 1
      %th 2
      %th 3
      %th 4
      %th 5

Upvotes: 13

Views: 7746

Answers (1)

Ry-
Ry-

Reputation: 224942

Looks like you want the colspan and rowspan attributes. Here's a demo.

%table
  %tbody
    %tr
      %th{:rowspan => 2} Name 
      %th{:colspan => 5} Sunday
      %th{:colspan => 5} Monday
      %th{:colspan => 5} Tuesday
      %th{:colspan => 5} Wednesday
      %th{:colspan => 5} Thursday
      %th{:colspan => 5} Friday
      %th{:colspan => 5} Saturday
    %tr
      - 7.times do
        %th 1
        %th 2
        %th 3
        %th 4
        %th 5

Upvotes: 19

Related Questions