1

I have a problem in making my div row centered, i have 3 posts from wordpress which is equivalent to 3 columns inside the row, but it didn't centered after i add many css attributes to let it center. I am also using wordpress.

screenshot

Here is my code :

<div class="row center-block">
<?php while ( $offerBlog->have_posts() ) : $offerBlog->the_post(); ?>
                        <div class="col-md-4 ">
                        <img src="<?php the_field('offer_image') ?>">
                        <br>
                        <br>
                        <h4><?php the_field('offer_title') ?></h4>
                        <?php the_field('offer_description') ?>
                        </div>
                    <?php endwhile; ?>

</div>

Here is my CSS:

.col-md-4 {
    width:15%;
    margin:0 2.5%;
    text-align: center
}
.center-block {
   margin-left:auto;
   margin-right:auto;
   display:center;
}
Jc John
  • 1,799
  • 2
  • 34
  • 69

1 Answers1

1

Try this:

Check demo HERE

CSS:

.center-block {
  display: flex;
  flex-direction: row;
  justify-content: center;
}

I hope it helps

Jyoti Pathania
  • 4,944
  • 1
  • 17
  • 29