I am trying to vertically center some divs in a bootstrap container that can resize due to another columns content. I want to do this without flexbox for backwards compatibility.
I am trying the translateY() trick but the parent row has 0 height so it centers itself on the top of the row instead of the middle.
I have read that floated items take the height of their children so I tried floating them but it still doesn't take the height.
How can I get this row to go 100% so the vertical centering works correctly?
.container{
margin-top: 60px;
}
.outer, .container{
border: 1px solid #000;
}
.row-center{
position: relative;
/* This needs to be 100% height but I can't figure it out */
/* I added the floats but it didn't help */
height: 100%;
float: left;
}
.outer{
position: absolute;
float: left;
top: 50%;
transform: translateY(-50%);
}
<div class="container">
<div class="row">
<div class="col-sm-5"><img src="http://placehold.it/350x500"></div>
<div class="col-sm-7 row-center">
<div class="outer">
<div class="one">some text</div>
<div class="two">some text</div>
</div>
</div>
</div>
</div>
(example code assumes that bootstrap css is referenced)
Code pen with bootstrap attached: http://codepen.io/GuerrillaCoder/pen/obJEgB