CSS align images and text on same line

后端 未结 9 1098
长情又很酷
长情又很酷 2020-12-05 06:16

I have been searching and trying different methods for hours now. I just can\'t seem to get these two images and text all on one line. I want both the images and both text

9条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-05 06:51

    You can simply center the image and text in the parent tag by setting

    div {
         text-align: center;
    }
    

    vertical center the img and span

    img {
         vertical-align:middle;
    }
    span {
         vertical-align:middle;
    }
    

    You can just add second set below, and one thing to mention is that h4 has block display attribute, so you might want to set

    h4 {
        display: inline-block
    }
    

    to set the h4 "inline".

    The full example is shown here.

    Take a photo

提交回复
热议问题