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

后端 未结 9 2001
灰色年华
灰色年华 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:06

    You can use contextual selectors and move the vertical-align there. This would work with the p tag, then. Take this snippet below as an example. Any p tags within your class will respect the vertical-align control:

    #header_selecttxt {
        font-family: Arial;
        font-size: 12px;
        font-weight: bold;
    }
    
    #header_selecttxt p {
        vertical-align: text-top;
    }
    

    You could also keep the vertical-align in both sections so that other, inline elements would use this.

提交回复
热议问题