I’m trying to achieve the following effect:
+----------------------+-----------------------------------+-----------------------+
| span (absolute left) | div consuming all space inbetween | span (absolute right) |
+----------------------+-----------------------------------+-----------------------+
On the surface it feels really straightforward; however:
- I don’t want to set the width of the left/right elements (I want them to ‘shrink-wrap’ automatically); and
- I don’t want to set the width of the all-consuming div (I want it to fill the arbitrary space).
I have been fiddling with relative positioning and floats for a while and am beginning to feel like I’m missing something obvious, since I’m so close. I’d be grateful to be put out of my misery 🙂
(Using a table just occurred to me – I’ll have another fiddle meanwhile.)
Thanks 🙂
Thanks bPratik! I had an epiphany when I read: floated columns begin “floating” at the point in the parent element’s text where they first appear.
The principle code I had was correct:
However, that creates the following:
Therefore, the order of elements has to be
span, span, div, otherwise the right-floating span is forced onto the line beneath (by the greedy div stealing it’s spot).Hence, the solution:
And subsequent result:
I hope that’s clear 🙂