Why are images centered vertically with `line-height` positioned 2 pixels below where they should be?

左心房为你撑大大i 提交于 2019-12-05 02:32:32

You have to set zero font-size for container div elements. Because images are displayed as inline elements they are affected by text in container div. Zero font-size fixes this:

.img-wrapper-center
{
    font-size:0;
}

Here is fiddle: http://jsfiddle.net/bZBsR/

If you also have text inside this div you can use this property:

.img-wrapper-center {
    display: flex;
    justify-content: center;
}

Here is fiddle: https://jsfiddle.net/rjurado/yvanL4k1/2/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!