How to set vertical center of img tag: html + css

I encode it

<div>
 <a href="http://example1.com">
   <img src="example1.gif" />
 </a>
</div>
<div>
 <a href="http://example2.com">
   <img src="example2.gif" />
 </a>
</div>

a {
  text-align:center;
  height :80px;
  display:block;
}

Centering the horizontal direction is good. but there is no vertical. How to do it? By the way, the height of example2.gif is different from example1.gif

0
source share
2 answers

This article may help - http://www.brunildo.org/test/img_center.html . Due to the need, it includes a bit of hacking for IE with a reduced version.

+5
source

You want to install vertical-align: middle;on your items img.

+1
source

Source: https://habr.com/ru/post/1727422/


All Articles