How to CSS a two column list of items?

前端 未结 7 764
萌比男神i
萌比男神i 2021-01-04 03:39

I need to display a two column list of items according to the following rules:

  • Container for the columns has fluid width
  • Width of both columns needs t
7条回答
  •  伪装坚强ぢ
    2021-01-04 04:02

    The problem with a-list-apart, from what I could see, is that if you split a list of 11 items into 2 colums, I would want the 6th item to be in the first list. alistapart I think puts the 11th item instead in the second column.

    My fix was to use jQuery-Columns Plugin. For example to split a ul with a class of .mylist into 2 columns you would do

    $(document).ready( function () {
      $('.mylist').cols(5);
    });
    

    Here's a live example on jsfiddle

提交回复
热议问题