0

I have 2 bootstrap col-md-6 columns that one has an image in and the other has a p tag in it with a paragraph of text. how would i dynamically vertically align the text so its perfect compared to the image next to it, code below

<div class="col-md-6">
    <img class="img-responsive" src="https://picsum.photos/550/430" >
</div>
<div class="col-md-6">
    <p>text goes here</p>
</div>

i also need to be able to do the same thing with a column that may have 3 tags in it so a h3 p and an a tag.

Temani Afif
  • 245,468
  • 26
  • 309
  • 415

1 Answers1

1

If you are using V4 of bootstrap you can simply rely on some class utilities and use align-items-center to achieve this:

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet">
<div class="container">
  <div class="row align-items-center">
    <div class="col">
      <img class="img-responsive" src="https://lorempixel.com/400/200/">
    </div>
    <div class="col">
      <p>text goes here</p>
    </div>
  </div>
</div>
Temani Afif
  • 245,468
  • 26
  • 309
  • 415