Center one element along with multiple siblings
|Added at||2016-12-31 16:12|
I have a div with some number of spans in it, that may or may not be of equal width. I know I can use
One idea I had to simulate this effect was: I'd have my desired middle element with two containers to its left and right; the left one would be right-justified, and vice-versa. These containers would hold the other content in the div. If I could get these two containers to fill up the remaining space in equal amounts, this would have the effect of centering the middle element while keeping the left and right content aligned with the center. Basically, this would require the two containers' width to be set to exactly half the remaining space in the div. (I don't want to change the size of the middle div.) Is this possible to do with just CSS?
Example: with 4 spans, how to I designate span 2 as the true center?