Hi all, I wonder if you can help me at all. I need to display one ul list into separate (3-4) columns one next to the other one, only if the number of items is bigger than 6.
Let's look at the following code.
Html is:
<div class="wrapper">
<h2 id="first">First</h2>
<ul id="items">
<li><a href="#">Product1</a></li>
<li><a href="#">Product2</a></li>
<li><a href="#">Product3</a></li>
<li><a href="#">Product4</a></li>
<li><a href="#">Product5</a></li>
<li><a href="#">Product6</a></li>
<li><a href="#">Product7</a></li>
<li><a href="#">Product8</a></li>
<li><a href="#">Product9</a></li>
<li><a href="#">Product10</a></li>
<li><a href="#">Product11</a></li>
<li><a href="#">Product12</a></li>
<li><a href="#">Product13</a></li>
<li><a href="#">Product14</a></li>
<li><a href="#">Product15</a></li>
<li><a href="#">Product16</a></li>
<li><a href="#">Product17</a></li>
<li><a href="#">Product18</a></li>
<li><a href="#">Product19</a></li>
<li><a href="#">Product20</a></li>
</ul>
<div class="clear"></div>
</div>
CSS:
.wrapper ul{
list-style: inside disc none;
color: #AC2973;
/* float:left; */
margin-right:11.189%;
margin-left:8px;
}
.wrapper ul#items li{
/*width:33%;
float:left; */
}
.wrapper ul li a{
font-size:0.875em;
line-height:1.428571428571429em; /*14/20*/
}
Now, I appreciate that there will be people saying "oh why don't you use multiple lists etc etc", the thing is, it's a bit complicated to explain, but the cms doestn' like multiple lists etc etc, so in essence I have to have 1 ul which display like multiple ones, one next to the other.
I have tried with css only, following this approach http://csswizardry.com/2010/02/mutiple-column-lists-using-one-ul/ but I will have problems displaying the list correctly on mobile devices so I need to do it via script.
I presume a script should look at the ul, determine whether there are more than 6 items, if so display the 7th item up to the 13th in a separate column and so on. Is it achievable? where would I start from?
Any advice is much appreciated
thanks