I have a div with dynamic height (its height depends on the image it contains).
And now I split the div into two part (up and down with 50% height).
So the div height will change according to the div width.
I want to make the up and down splitting div to align middle vertically, but the display: table-cell; vertical-align: middle;
approach seemed doesn't work here.
http://jsfiddle.net/fish_ball/MhY3M/
Need your help!
HTML mark up:
<div id="outer">
<img id="inner-back" src="http://www.google.cn/landing/cnexp/google-search.png" />
<div id="inner-up">upper-text</div>
<div id="inner-down">upper-down</div>
</div>
CSS stylesheet:
#outer {
position: fixed;
left: 0;
right: 0;
top: 0;
}
img#inner-back {
width: 100%;
}
#inner-up {
position: absolute;
top: 0;
left: 0;
right: 0;
height: 50%;
background-color: blue;
opacity: 0.5;
color: white;
text-align: center;
display: table-cell;
vertical-align: middle;
}
#inner-down {
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 50%;
background-color: green;
opacity: 0.5;
color: white;
text-align: center;
display: table-cell;
vertical-align: middle;
}