简体   繁体   English

垂直对齐多行文本?

[英]Vertically align more than one line of text?

I'm using: 我正在使用:

#leftfoot {padding-left: 20px; vertical-align: middle;}

It does not work. 这是行不通的。 I've look at plenty of explanations, none of them seem to work for me. 我看了很多解释,其中没有一个似乎适合我。 Does anybody else know how to vertically align more than one line of text? 有没有人知道如何垂直对齐多行文本?

Shakes fist angrily at CSS. 在CSS上愤怒地握拳。

#leftfoot {
    height: 110px;
    display:table-cell;
    vertical-align: middle;
    padding-left: 20px;
}

Your issue is the following: Your text was indeed centered vertically, but your inner div had just the same height as the text and was not extending to the bounds of the outer div, so you have to set a height for the inner div to work. 您的问题如下:您的文本确实是垂直居中的,但您的内部div与文本的高度相同,并且未扩展到外部div的边界,因此您必须设置内部div的高度才能工作。

Your question is not clear, create a JsFiddle. 你的问题不明确,创建一个JsFiddle。 For better understanding of Vertical-align http://css-tricks.com/what-is-vertical-align/ 为了更好地理解垂直对齐http://css-tricks.com/what-is-vertical-align/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM