Essentially, I’m trying to achieve the affect of “text-align:justify” but with floating block elements. I have many blocks that I want to justify-align.
Ie. each line is horizontally-spaced differently to make sure lengths of each line are the same. (Non-ragged right edge).
Is there a way to do this with CSS? If not, is there a suitable JS library to achieve this? Or is this just infeasible?
If the items are not actually
floating, you can useposition:absolute; left:1em; right:1emto have CSS calculate the widths of the items for you based on offsets from some positioned parent.If you are only using
floatbecause you have some block-level items you are trying to make flow, usedisplay:inline-blockon the items instead of floating them. If the parent element hastext-align:justifythis should give you the effect (I imagine that) you want.Here is a simple test showing you the result of
inline-blockwithtext-align:justify.Edit: I’ve updated the simple test to more clearly show that the left and right edges are always aligned except for the last line.