How do I put text that is inside a P element next to a image?

前端 未结 4 1089
感情败类
感情败类 2021-01-19 23:58

Here is my code:


This is some example text that i want next to th

4条回答
  •  Happy的楠姐
    2021-01-20 00:18

    you can do it without changing the html structure

    As img is a inline element you can set the next sibling p to inline

    By default p is a block element so it is taking full width

    more about + selector

    img + p {
      display: inline;
      margin-left: 10px;
      vertical-align: top; /* so that p aligns to the top of img*/
    }
    
    

    This is some example text that i want next to the image on the right hand side

提交回复
热议问题