I need to display a two column list of items according to the following rules:
Here is an example:
~ Item 1 | ~ Item 6
~ Item 2 | ~ Item 7
~ Item 3 | ~ Item 8
~ Item 4 | ~ Item 9
~ Item 5 |
The HTML can be anything as long as it solves this problem. I'm restricted to using XSLT to wrap HTML around what the server spits out. I have access to two XSLT parameters: one that tells me the current item number and one that tells me how many items there are.
My CSS skills are basic/intermediate and I don't know where to start here. Any ideas on whether this is achievable and how to do it?
Update:
Thanks for the answers. Consensus seems to be either use the A List Apart article or a table which I'd prefer as it's simpler. The problem with the table is that the server gives me the items in sorted order. To use a table would mean XSLT trickery to re-sort, wouldn't it?
<tr>
<td>Item 1</td>
<td>Item 4</td>
</tr>
<tr>
<td>Item 2</td>
<td>Item 5</td>
</tr>
<tr>
<td>Item 3</td>
<td> </td>
</tr>
This is the simplest way to do it. CSS only. add width to the ul element. add display:inline-block and width of the new column (should be less than half of the ul width).
Create a list with as many list elements as you want. Then enclose the list in a div, setting style=column-width and style=column-gap, to match the information in your list elements. Do not set style=columns. Totally responsive list that adapts to screen size.
You just need the CSS multi-column properties, e.g.
ul { column-count: 2; }
.
See Can I Use for support information on CSS Columns.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With