2

i am trying to get an unorder list to appear like this:

enter image description here

How can this alignment be achieved? thanks for any help!

Prashobh
  • 9,216
  • 15
  • 61
  • 91
Stinis87
  • 140
  • 3
  • 14

4 Answers4

2

For this type of functionality you can use column-count property. Write like this:

ul{
    -moz-column-count: 4;
    -webkit-column-count: 4;
    column-count: 4;
}

For more check this I want to show list items as 2 or more columns (dynamic alignment)

Note: It does not work in IE.

For IE, you can use this JavaScript: CSS3 - Multi Column Layout Demonstration

Community
  • 1
  • 1
sandeep
  • 91,313
  • 23
  • 137
  • 155
0

i hope this will work for you :- http://tinkerbin.com/BAzYZaPY

you can you desired result through column-widthproperty

The column-width property is only supported in Opera.

Firefox supports an alternative, the -moz-column-width property.

Safari and Chrome support an alternative, the -webkit-column-width property.

Shailender Arora
  • 7,674
  • 2
  • 31
  • 35
0

or you can try

<ul>
<li>cont</li>
<li>cont</li>
<li>cont</li>
</ul>
<ul>
<li>cont</li>
<li>cont</li>
<li>cont</li>
</ul>
<ul>
<li>cont</li>
<li>cont</li>
<li>cont</li>
</ul>

ul
{
  float:left;
}
Prashobh
  • 9,216
  • 15
  • 61
  • 91
0

You can try this style (below). Number of columns will change dynamically depending on number of elements and available width.

<style>
   ul > li
   {
      list-style-type: none;
      display: block;
      float: left;
      width: 120px;
   }
</style>
<ul>
    <li>Barn</li>
    <li>Data</li>
    <li>Design</li>
    <li>Lov og rett</li>
    <li>Matt</li>
    <li>Musikk</li>
    <li>Barn</li>
    <li>Data</li>
    <li>Design</li>
    <li>Lov og rett</li>
    <li>Matt</li>
    <li>Musikk</li>
    <li>Barn</li>
    <li>Data</li>
    <li>Design</li>
    <li>Lov og rett</li>
    <li>Matt</li>
    <li>Musikk</li>
</ul>

If you want to have fixed number of columns set width on ul element (multiply number of columns by the width of list element, e.g. in this case you want 5 columns set width to 600px):

ul {
    width: 600px;
}