Why is vertical-align:text-top; not working in CSS

后端 未结 9 2000
灰色年华
灰色年华 2020-12-25 09:16

I want to align some text to the top of a div. It seems that vertical-align: text-top; should do the trick, but it doesn\'t work. The other things that I have d

9条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-25 10:09

    The vertical-align attribute is for inline elements only. It will have no effect on block level elements, like a div. Also text-top only moves the text to the top of the current font size. If you would like to vertically align an inline element to the top just use this.

    vertical-align: top;
    

    The paragraph tag is not outdated. Also, the vertical-align attribute applied to a span element may not display as intended in some mozilla browsers.

提交回复
热议问题