I am trying to vertically align some text next to an image using Twitter Bootstrap 3
<div class="col-sm-4">
<img class="img-circle" src="http://dummyimage.com/100x100/000/fff">
<h2>
Short title
</h2>
</div>
<div class="col-sm-4">
<img class="img-circle" src="http://dummyimage.com/100x100/000/fff">
<h2>
A longer title
</h2>
</div>
https://jsfiddle.net/DTcHh/23814/
Sometimes my titles are on one line and sometimes they are on two. This means I am unable to set a static margin to get the text to be vertically centered.
Whats the best way to achieve this and does anybody have an example I can see?
2
Answers
You have options for this, but one of them is using flex:
You can simply do it by using the flexbox layout:
Fiddle: https://jsfiddle.net/pavelrich/f5hyvbwq/