Align content in the middle of div

Viewed 70

I'd like to align the content of my second column in the middle of the div. I did try in a lot of different ways but so far I haven't found how.
I'm using Bootstrap 4.

Could you tell me how to do it ?

<div class="card">
   <div class="card-body">
      <div class="row">
         <div class="col-md-1">
            <img class="rounded-circle img-thumbnail d-inline"
                 src="..."
                 height="65px"
                 width="65px"
                 alt="User image">
         </div>
         <div class="col-md-11">
            <p class="d-inline">...</p>
            <button class="close" type="button"><span class="fa fa-times" aria-hidden="true"></span></button>
         </div>
      </div>
   </div>
</div>

I'm sure I miss something very simple but don't know what.

JSFiddle exemple

Thanks for your help :)

3 Answers

Use text-center class.

 <div class="card">
  <div class="card-body">
    <div class="row">
      <div class="col-md-1">
        <img class="rounded-circle img-thumbnail d-inline" src="https://4fi8v2446i0sw2rpq2a3fg51-wpengine.netdna-ssl.com/wp-content/uploads/2016/06/KittenProgression-Darling-week7.jpg" height="65px" width="65px" alt="User image">
      </div>
      <div class="col-md-11 text-center"><!--Modification here -->
        <p class="d-inline">Kitten</p>
        <button class="close" type="button"><span class="fa fa-times" aria-hidden="true"></span></button>
      </div>
    </div>
  </div>
</div>

Demo: https://jsfiddle.net/2hjxszck/1/

To get it vertically center

<div class="col-md-11 align-self-center">
    <p class="d-inline">Kitten</p>
    <button class="close" type="button"><span class="fa fa-times" aria-hidden="true"></span></button>
</div>

Add this css to vertically and horizontally center

button.close {
    padding: 0;
    background: 0 0;
    border: 0;
    -webkit-appearance: none;
    line-height: 65px;
    text-align: center;
}
.d-inline {
    display: inline!important;
    line-height: 65px;
    text-align: center;
}

and text-center class to col-md-11 <div class="col-md-11 text-center">

Related