I'm trying to solve a vertical-align
problem involving the floating divs. All the heights are unknown - because they are implicitly formed only with the inside text lines.
Here's the code: https://jsfiddle.net/zjzyryae/
#test {
background: yellow;
display: inline-block;
}
#block1 {
float: left;
display: inline-block;
background-color: grey;
}
#block2 {
background-color: green;
float: left;
}
<div id="test">
<div id="block1">
<div>test</div>
<div>test</div>
<div>test</div>
<div>test</div>
<div>test</div>
<div>test</div>
<div>test</div>
<div>test</div>
<div>test</div>
<div>test</div>
</div>
<div id="block2">
sample
</div>
</div>
I need to vertically center the "block2" div - with CSS only of course (no JavaScript).
See that "block1" div sets implicitly the parent "test" block height - which makes the principal difference with the similar described cases (where this height is explicitly set in pixels).
Perhaps this question is solved somewhere but I haven't found exactly the same case. The similar examples I considered were different.
This one Center vertically a unknown height text in a unknown height div actually includes the hard-coded height setting - which is dramatically different case than mine.
That one How to vertically middle-align floating elements of unknown heights? is also different case and not suitable for my situation - because the parent height is equal to the floating divs height (which is much easier than my case).
I tried to play with different display:table
settings - but still no luck.