This is possible using the "Flex" property. See: http://jsfiddle.net/dsmzz4ks/
In the script, reduce the width of the window. You will see that all the elements of the list that do not suit you will be completely removed until the window is enlarged again.
This is a little suspicious as it adds a marker using the li:before
clause, but works nonetheless.
CSS:
.box { width: 30%; float: left; margin: 8px 16px 8px 0; position: relative; border: 1px solid black; padding: 15px; } ul { height: 90px; display: flex; flex-direction: column; flex-wrap: wrap; overflow: hidden; padding-left: 15px; justify-content: space-around; margin: 0; } li { display: block; width: 100%; padding-left: 10px; position: relative; } li:before { content: '\2022'; position: absolute; left: -5px; }
The key properties here are that display: flex
uses the flex box on the parent element. flex-direction: column
ensures that the order of the elements is vertical, and flex-wrap: wrap
wraps any overflow element in another column. This can be shortened to:
display: flex; flex-flow: column wrap;
If all child elements behave in such a way that they cover the entire width of their parent element, then this means that any overflow elements are transferred to another column, effectively hiding from viewing and avoiding any clipping.
source share