Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HAML: table column's width not working

Nothing from this not working. When I typing large text table going deep right and horizontal nav appears.

index.haml

%table{:border => 1, :width => "100%"}
  %tr
    %th{:width => "200"} Name
    %th.edit Edit

  - @wallpapers.each do |wallpaper|
    %tr
      %td.name= wallpaper.name
      %td= link_to (image_tag wallpaper.thumb.url(:thumb)), edit_wallpaper_path(wallpaper)
      %td= button_to 'Delete', wallpaper_path(wallpaper), :confirm => 'Are you sure you want to delete this wallpaper?', :method => :delete

style.css

th.edit {width:20%;}
td.name {width:20%;}
like image 953
TiSer Avatar asked Apr 16 '26 16:04

TiSer


1 Answers

You really want to set the style, not html attributes

Try this:

%table{:style=>"border: 1px; width: 100%"}

What you're actually creating is:

<table border="1" width="100%">

And you should be creating:

<table style="border: 1px; width: 100%">

of course, using classes and CSS would be better, but this will solve immediate concern.

like image 157
Jesse Wolgamott Avatar answered Apr 19 '26 10:04

Jesse Wolgamott