My goal is to create a horizontal unordered list (<ul>
) with four columns in each row.
The number of list items (<li>
) may vary and change during runtime.
Existing Code and Outcome
ul {
-webkit-columns: 4; /* Chrome, Safari, Opera */
-moz-columns: 4; /* Firefox */
columns: 4;
display: block;
}
ul li {
margin: 20px ;
padding: 10px;
text-align: center;
color: white;
display: list-item;
}
But the current setup produces this result: https://i.sstatic.net/0TWQU.png
The list appears somewhat horizontally, yet the second element (Green) is positioned below the first one (Blue) and beside it. However, for my purpose, the order of elements doesn't really matter.
The issue lies in the fact that the padding of the element extends into the next column.
Any recommendations on how to address this?
View JSfiddle link here