Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wrap a list to the right

Tags:

html

css

If i had a list like the following:

<ul>
  <li>Alex</li>
  <li>James</li>
  <li>Thomas</li>
  <li>Is</li>
  <li>Asking</li>
  <li>Questions</li>
  <li>On</li>
  <li>Stackoverflow</li>
</ul>

The default will be displayed like:

* Alex   
* James
* Thomas
* Is
* Asking
* Questions
* On
* Stackoverflow

What CSS would i use to get it to display like:

* Alex     * Questions
* James    * On
* Thomas   * Stackoverflow
* Is
* Asking

Thanks in advance...

like image 302
Alex Avatar asked Jun 24 '11 12:06

Alex


2 Answers

For modern browsers

ul{
    -ms-column-count: 2;
    -o-column-count: 2;
    -moz-column-count: 2;
    -khtml-column-count: 2;
    column-count: 2;
    }
like image 106
Nikhil Bhandari Avatar answered Oct 07 '22 12:10

Nikhil Bhandari


If you would like set width for every <li> and lost order of elements, here is demo: http://jsfiddle.net/dpXz2/

li{
    display: block;
    float: left;
    width: 75px;
}

ul{
    width: 150px;
}
like image 26
IProblemFactory Avatar answered Oct 07 '22 12:10

IProblemFactory