3

I have an unordered list that gets dynamically filled with list-items from 1 up to anything. This list is styled as columns using column count. If there are more 3 ore more items in the list, everything is fine. But when there are two or only one item I want to position them in the middle.

HTML:

<ul class="list">
    <li class="list-item">Text</li>
    <li class="list-item">Text</li>
 </ul>

CSS:

.list { 
    -moz-column-count: 3;
    -moz-column-gap: 1px; }`

.list-item {
    position: relative;
    padding: 0.46667rem 1.2rem;
    overflow: hidden;
    border-bottom: 1px solid #FFF;
    background-color: #EEE;
}

Demo: http://codepen.io/anon/pen/NPBKBd

Here is an image:

enter image description here

Wubbel
  • 53
  • 1
  • 6

1 Answers1

4

I would wrap it in a wrapper and apply margin auto to left/right or check out this plugin

.container{
  width:500px;
  margin-left:auto;
  margin-right:auto;
}