Align Images without spacing horizontally and veritcally

前端 未结 3 414
春和景丽
春和景丽 2021-01-14 16:43

I have a group of 4 images that I\'m trying to align vertically and horizontally.

The problem:

I cant get ride of a a small vertical spacing between them.

相关标签:
3条回答
  • 2021-01-14 17:06

    Adding vertical-align:top on the img elements will remove the gap. The default is baseline.

    As a side note, bottom and middle work too.

    jsFiddle example

    img {
        vertical-align:top;
    }
    

    Adding display:block to the img elements works too. (example)

    img {
        display:block;
    }
    
    0 讨论(0)
  • Try margin: 0 auto; border: 0px;

    0 讨论(0)
  • 2021-01-14 17:12

    If you don't have text in this you can just say

    ul {
        font-size: 0;
    }
    

    This eliminates the space, see modified JSFiddle

    0 讨论(0)
提交回复
热议问题