Vertical-align image

前端 未结 7 1207
梦如初夏
梦如初夏 2020-11-29 04:21

I have a div that contains an image and a p tag (seen below). I want to align the image in the middle of the div vertically depending on how many lines the paragraph is. Ver

7条回答
  •  既然无缘
    2020-11-29 05:17

    the CSS vertical-align attributes only works on table cells and inline elements. Since the paragraph tag specifies a block element by default, it does nothing. In order for your text to be aligned as you describe, you either have to separate your div into two containers or use a table. Here's a good page to help you understand a little bit better: Understanding vertical-align

提交回复
热议问题