I’m trying to figure out what is the best method in bootstrap 3 to align an element vertically.
I searched in the documentation and i didn’t find any special class per the vertical align.
I would like that the text and the image are align vertically.
any idea?
This is my jsfiddle http://jsfiddle.net/ttfgL6ns/1/
<div class="container-fluid">
<div class="row">
<div class="scenes green">
<div class="col-xs-6 col-md-6">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do</div>
<div class="col-xs-6 col-md-6">
<img src="http://lorempixel.com/400/200" />
</div>
</div>
</div>
</div>
Moreover, it is more correct to add a div before or after the div with the class row (<div class "row"
)?
thanks
4
Answers
using bootstrap you need to configure on DIV parent the
height
before. After that, on DIV child, you usetop:50%
like this:I hope it help you.
in your case margin- and padding- of scenes and green classes should drive the alignment style. the answer for better choice between before/after is irrelevant, “rows” just tells to the browser to render a responsive
<table><tr>
and all the children divs found with col- classes are splitted to responsive<td></td>
scenes and green styles before the class “row” apply the format to the same elements if declared after
Try with vertical-align: middle property works only for display: table-cell; element. Second thing is vertical align works only for display:inline; elements.
and your css
You need to add class “col-md-12 col-xs-12” to father of class col-md-6 col-xs-6
Like this: