L
L
ligisayan2016-10-31 17:35:14
css
ligisayan, 2016-10-31 17:35:14

How to center images of any size vertically and horizontally in a row?

There is a grid with pictures in 4 columns. I'm struggling with how to center images on the vertical and horizontal center at any resolution, regardless of the size of the image (height). How to do this using only styles, not scripts and without using flex , because. Do you need ie9+ crossbrowser support ? Fiddle

<div class="row">
  <div class="col-sm-3 col-xs-3">
    <img src="http://placehold.it/70x81">
  </div>
  <div class="col-sm-3 col-xs-3">
    <img src="http://placehold.it/100x33">
  </div>
  <div class="col-sm-3 col-xs-3">
    <img src="http://placehold.it/100x19">
  </div>
  <div class="col-sm-3 col-xs-3">
    <img src="http://placehold.it/80x72">
  </div>
</div>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
iBird Rose, 2016-10-31
@ligisayan

https://jsfiddle.net/iBird/mt6tv6xu/2/

K
Kovalsky, 2016-10-31
@lazalu68

Well , you can try using vertical-align and a helper element. Here it is written how it works and how you can additionally finish it so that it reaches IE.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question