Reputation: 1902
I am looping through countries to get the list of the countries in alphabetical order. The desired form of display is as shown in the image below:
However I am currently getting it like this
I am using unordered list to achieve the desired result.
Here is the code :-
Code in the view :-
<% User.find(:all, :order => "name").group_by(&:initial).each do |initial, users| %>
<table>
<ul>
<li><%= content_tag(:h3, initial)%> </li>
</ul>
<% users.each do |user|%>
<ul>
<li> <%= link_to(user.name, user)%> </li>
</ul>
<% end %>
</table>
<% end %>
CSS:-
ul {
list-style: none;
}
Could anyone please guide me?
Thanks
Upvotes: 3
Views: 1751
Reputation: 1
Try to use the below CSS only to your div,
column-width: 300px; column-gap: 20px;
It would align to multiple columns if you are resizing the browser also.
Upvotes: 0
Reputation: 27630
Assuming that each letter + it's children is a li
, and the ol
is the surrounding tag, you could use something like:
ol {
-moz-column-count: 3;
-webkit-column-count: 3;
column-count: 3;
}
Example: http://jsfiddle.net/rDQe5/1/
Mind you though that some browsers (esp. older IE versions) don't support this.
After you updated your question with code, some things:
div
.ol
), each letter is a li
, and then for each country per letter another list (but this time unordered). I've updated my example to reflect that better.Upvotes: 5