html - Bootstrap - Center img in row vertically -


i've been trying forever center image in row containing div img in. here's html

            <div class="row">             <div class="col-md-9">                 <div class="col-md-12">                     <h3 style="text-transform: uppercase"><strong>title</strong></h3>                     <p>text</p>                     <br>                     <h3 style="text-transform: uppercase"><strong>title</strong></h3>                     <p>text</p>                     <br>                     <h3 style="text-transform: uppercase"><strong>title</strong></h3>                     <p>text(2 male, 1 female, 3 mixed characters)</p>                 </div>             </div>             <div class="col-md-2">                 <img class="img-full center-block" src="img/img.jpg" alt="">             </div>         </div> 

i've tried suggestions on page , none of them seem work. https://css-tricks.com/centering-css-complete-guide/

i not know height of element since responsive website, tried using translate move image, , happened.

enter image description here

if use flexbox, mobile design breaks because columns don't collapse right, this.

enter image description here

if use code

.vcenter { display: inline-block; vertical-align: middle; float: none; } 

nothing happens

enter image description here

so feel i've exhausted known solutions. have idea how fix this? have feeling issue linked stacking columns within columns, if don't breaks design too...

edit: how want look

enter image description here

at point won't able vertically align image because containing col-md-2 shrink down height of image. you'll need ensure parent element of image has larger height value. can set height of col-md-9 statically in css (like have done in snippet) or have check dynamically javascript. can run code have below (the css work ie 9 , up, changed bootstrap class xs illustrate in snippet):

.vcenter {  position: relative;    top: 50%;    transform: translatey(-50%);  }  .taller{ height:300px;
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>    <div class="container">  <div class="row">              <div class="col-xs-9">                <div class="row">                  <div class="col-md-12">                      <h3 style="text-transform: uppercase"><strong>title</strong></h3>                      <p>text</p>                      <br>                      <h3 style="text-transform: uppercase"><strong>title</strong></h3>                      <p>text</p>                      <br>                      <h3 style="text-transform: uppercase"><strong>title</strong></h3>                      <p>text(2 male, 1 female, 3 mixed characters)</p>                  </div>                </div>              </div>              <div class="col-xs-2 taller">                  <img class="img-full center-block vcenter" src="img/img.jpg" alt="">              </div>          </div>  </div>    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

this should javascript version

$(document).ready(function(){     matchcolheight();  });    $(window).resize(function(){      matchcolheight();  });     function matchcolheight() {    var col1_height = $('.col1').height();     $('.col2').css('height', col1_height);    }
.vcenter {      position: relative;        top: 50%;        transform: translatey(-50%);      }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>  <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>      <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>        <div class="container">      <div class="row">                  <div class="col-xs-9">                    <div class="row">                      <div class="col-md-12 col1">                          <h3 style="text-transform: uppercase"><strong>title</strong></h3>                          <p>text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text </p>                          <br>                          <h3 style="text-transform: uppercase"><strong>title</strong></h3>                          <p>text</p>                          <br>                          <h3 style="text-transform: uppercase"><strong>title</strong></h3>                          <p>text(2 male, 1 female, 3 mixed characters)</p>                      </div>                    </div>                  </div>                  <div class="col-xs-2 col2">                      <img class="img-full center-block vcenter" src="img/img.jpg" alt="">                  </div>              </div>      </div>        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>


Comments