You can: by dubbing " dual parental support ":
For a similar problem, I defined an external relative object (the parent of the floats) and an absolutely defined field of the same dimensions as the relative parent, starting from 0,0 of the general (relative) parent: an identical copy that allows placing objects inside it can ignore the outer limits of the float (I needed to focus the object on the page, regardless of the width of the dynamic floats.)
“Double parenting” crushed both problems:
- the absolute parent could not get the height of the floats (but the height of the mutual parent, who was able to adapt to the floats).
- the relative parent could not position the object centered on the page (he would only find the middle between the floats and leave the centered content crossing the boundaries of the floating objects).
I made a fiddle (contains documentation) demonstrating how this setting penetrates and compresses while maintaining the center frame. The basic idea is described in the code below:
HTML (side note: the order of the div (left-right-right, center-right-left, ...) does not matter.)
<header> <div class="header-left">left</div> <div class="header-center"> <div class="centerinner">middle</div> </div> <div class="header-right">right</div> </header>
CSS
header { position:relative; width: 100%; margin:0; padding:0; vertical-align: top; } .header-left { float:left; display:block; } .header-center { position:absolute; left: 0; width: 100%; height:100%; } .centerinner { margin-left:45%; margin-right:45%; padding-left: 1ex; padding-right: 1ex; background-color: #D6A9C9; width: -moz-fit-content; width: -webkit-fit-content; width: fit-content; height:100%; } .header-right { float:right; text-align: right; padding-left: 1ex; color: forestgreen; }
Tatjana Heuser
source share