CSS align images and text on same line

后端 未结 9 1119
长情又很酷
长情又很酷 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 07:07

    This question is from 2012, some things are changed from that date, and since it still receives a lot of traffic from google, I feel like completing it adding flexbox as a solution.

    By now, flexbox is the advised pattern to be used, even if it lacks IE9 support.

    The only thing you have to care about is adding display: flex in the parent element. As default and without the need of setting other property, all the children of that element will be aligned in the same row.

    If you want to read more about flexbox, you can do it here.

    .container {
      display: flex;
    }
    
    img {
      margin: 6px;
    }
    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

提交回复
热议问题