Sorry if the title is confusing. I mainly work on a tumblr theme where I need three contiguous divs wrapped in a fixed-width container. None of their contents are fixed, so they all have a variable width. The middle div should always be centered in the container, while the divs on the left and right will always touch the middle div and thus move as the average width of the div changes (there may be images on the left and right, so text-align does not always work) . In addition, I may also need to hide the left, right, or both left and right divs.
Here is a conceptual image:

I can easily get this with flexboxes ( JFiddle ), but flex only has 86% global support .
This is the closest I could get without using flexboxes, but I can't get this middle div (with text) centered on the div header, while preserving the relative positions of the two images on both sides: JFiddle
* { height: 100%; position: relative; } body { height: 200px; } /* just to get rid of scrollbar */ p { margin: 0; } .title { background: #aaa; height: 22px; width: 450px; /* for example */ margin: 0 auto; } .container { background: #abc; float: left; } .lr { transform: translate(0, -100%); } .left { background: green; float: left; } .left img { transform: translate(-100%); } .center { background: red; display: inline-block; z-index: 2; } .right { background: blue; float: right; } .right img { transform: translate(100%); } .left img, .right img { height: 100%; } <div class="title"> <div class="container"> <div class="center">CENTERCENTERCENTERCEN</div> <div class="lr"> <div class="left"> <img src="http://i.imgur.com/7bvErJN.jpg" /> </div> <div class="right"> <img src="http://i.imgur.com/q8Mq0YZ.jpg" /> </div> </div> </div> </div>
Other people mentioned an attempt to display the title in a table, but for this it would be necessary to center the middle cell on the entire row, and the cells on the left and right to occupy the rest of the space, and I'm not sure if you can do this when their width is not fixed.
Does anyone know of any other solutions?
source share