I was given a design for creating in HTML / CSS, which, I think, may not be possible, but I want to be absolutely sure before I lose and compromise.
Several elements containing variable-length text are grouped in groups of two such that they form columns, where the columns are precisely distributed over the available width, but each column is not wider than its widest point. Thus, it uses horizontal space as efficiently as possible, while keeping the elements perfectly aligned like a grid. Consider this example -
[-a--] [-cccccc-] [-eee-] [-g---] [-bb-] [-dddd---] [-ff--] [-hhh-]
It may look tabular, but keep in mind that the elements should also be wrapped when the container is compressed and the columns retain their magical alignment -
[-a---] [-cccccc-] [-bb--] [-dddd---] [-eee-] [-g------] [-ff--] [-hhh----]
I cannot decide how to solve the recursive width dependency. That is, the width of each βcolumnβ is determined by the longest element in that column, but the total available width is known and must be the exact sum of the width of the columns.
I enjoy using only the CSS3 solution, returning to the fixed element width solution for older browsers, but I'm completely fixated on what CSS properties can achieve this magic.
Just to provide some kind of starting point, here is Codepen using CSS3 columns: http://codepen.io/anon/pen/kiGgp
This is useless since the columns are evenly distributed, and I wonder if there is a way to distribute them optimally.
source share