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

后端 未结 9 1962
灰色年华
灰色年华 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条回答
  • 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.

    0 讨论(0)
  • 2020-12-25 10:10

    vertical-align is only supposed to work on elements that are rendered as inline. <span> is rendered as inline by default, but not all elements are. The paragraph block element, <p>, is rendered as a block by default. Table render types (e.g. table-cell) will allow you to use vertical-align as well.

    Some browsers may allow you to use the vertical-align CSS property on items such as the paragraph block, but they are not supposed to. Text denoted as a paragraph should be filled with written-language content or the mark-up is incorrect and should be using one of a number of other options instead.

    I hope this helps!

    0 讨论(0)
  • 2020-12-25 10:12

    The all above not work for me, I have just checked this and its work :

    vertical-align: super;

     <div id="lbk_mng_rdooption" style="float: left;">
         <span class="bold" style="vertical-align: super;">View:</span>
     </div>
    

    I know by padding or margin will work, but that is last choise I prefer.

    0 讨论(0)
提交回复
热议问题