To achieve a multi-column layout in CSS, you can make use of the CSS property called columns
, specifically utilizing column-count
.
HTML Code
<div class="wrapper">
<ul>
<li>Item</li>
<li>Item</li>
<li>Item</li>
<li>Item</li>
<li>Item</li>
<li>Item</li>
<li>Item</li>
<li>Item</li>
<li>Item</li>
</ul>
</div>
CSS Styling
/* Medium-sized devices (768px and up) */
@media (min-width: 768px) {
ul {
-webkit-column-count: 2; /* for Chrome, Safari, Opera */
-moz-column-count: 2; /* for Firefox */
column-count: 2;
padding: 0;
}
ul > li {
margin: 0 2rem; /* necessary to display bullets properly */
}
}
/* Large-sized devices (992px and up) */
@media (min-width: 992px) {
ul {
-webkit-column-count: 3; /* for Chrome, Safari, Opera */
-moz-column-count: 3; /* for Firefox */
column-count: 3;
}
}
Final Outcome
Display on medium-sized devices:
https://i.sstatic.net/ghmBC.png
View on large devices:
https://i.sstatic.net/WJbk9.png
See it in action: http://jsfiddle.net/r74ctfy6/