Is there a way to do re-flowable, multi-column lists, where the list can have list items of varying heights, using only valid CSS? By re-fl
I recently had the need to use multi-column lists in a project. We're using CSS3 columns and ran into several little gotchas along the way. I posted a write-up about it here: http://bit.ly/css3lists
The short of it is this:
In fact the single command does the trick for me (although it comes in -webkit-
and -moz-
versions):
div.wrapper
{
-webkit-column-width: 10em;
-moz-column-width: 10em;
}
Here are additional rules to improve readability. Insert the code below and above into an example from A List Apart article (I can paste the whole HTML if somebody clears copyright) and enjoy:
div.wrapper {
border: 2px solid blue;
-webkit-column-rule: 2px solid blue;
-moz-column-rule: 2px solid blue;
}
.wrapper ol {
margin: 0;
}
.wrapper br {
display: none; /* Extra BR is unnecessary there */
}
Tested: Safari 4 (4528.17), Fx 3.5b4 /Mac.
Note that on the first encounter of column-width properties some time ago I completely missed the crucial fact that it does rebalancing. Discovered it now at W3C and confirmed with Surfin' Safari.
As I understand from the clarification, the width of columns should change with the widthof the page, so the commands are more like
div.wrapper
{
-webkit-column-count: 3;
-moz-column-count: 3;
}
Now you say that there should be a vertical scrollbar. Since there is no UI that would do separate scrollbars to the right of each column, I think you have in mind one scrollbar that would scroll the whole multicolumn list. That can be done by wrapping one more div
with
div.morewrap
{
height: 50%; /* whatever you need */
overflow-y: scroll;
}
Using CSS multi-column layouts, it's possible to specify either the number of columns (which will get wider or narrower as you resize) OR the width of the column (which will cause new columns to be added or removed as you resize):
ul li {
margin-left: 1em; /* needed to preserve bullets */
column-break-inside: avoid; /* don't forget this */
}
ul {
list-style: outside disc;
padding-left: 0.5em;
column-width: 150px; /* actually the minimum width */
}
http://jsfiddle.net/mblase75/XtzLF/
I realize this is an old post, but I just got this working on my project, and Ilya's solution did not work for me (though maybe I missed something). Anyway, the problem is that with CSS3 columns (now a Candidate Recommendation) the overflow wants to go off to the right by creating additional columns, and if you have overflow:auto you end up with a horizontal scrollbar, instead of a vertical one (which the OP wanted, and I also wanted). I fixed this by wrapping the div that held the columns (with -moz-column-count set) inside another div, and setting the height on that one with overflow-y:auto. The meant that the outer div could scroll vertically, while the inner div with the columns had as much height as it needed and did not need to overflow horizontally.
I hope the helps.
Not through plain CSS, no. There might be a JavaScript implementation somewhere, but I don't know of any fluid ones as you describe.