DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Zebra Stripes On Table Rows Using Rails / RHTML
<% @projects.each_with_index do |project, i| %> <% row_class = i%2 == 0 ? "even" : "odd" %> <tr class="<%= row_class %>"> ...... <% end %>
In the CSS:
TR.even { background-color: #f00; }
TR.odd { background-color: #f00; }etc..






Comments
Snippets Manager replied on Wed, 2009/07/15 - 3:38pm
Snippets Manager replied on Mon, 2008/01/07 - 10:29pm
table tr.rowA {background-color: white; } table tr.rowB {background-color: silver; }View<% @projects.each do |project| -%>">...
<% end -%>
Snippets Manager replied on Tue, 2007/11/13 - 7:40pm
Snippets Manager replied on Tue, 2007/11/13 - 7:40pm
<% @projects.each_with_index do |project, i|%>>
...
<% end %>
And in the css :table td {background-color: white; } table td.stripe {background-color: silver; }