Center Text Vertically Within

后端 未结 7 2107
孤独总比滥情好
孤独总比滥情好 2020-12-05 16:57

I have a

element with a fixed height, and I\'d like to center some text vertically within that element.

I\'ve been trying to follow the inst

7条回答
  •  温柔的废话
    2020-12-05 17:32

    This:

    
    
    
    

    This text will be vertically aligned

    This longer text will be vertically aligned. Assumenda quinoa cupidatat messenger bag tofu. Commodo sustainable raw denim, lo-fi keytar brunch high life nisi labore 3 wolf moon readymade eiusmod viral. Exercitation velit ex, brooklyn farm-to-table in hoodie id aliquip. Keytar skateboard synth blog minim sed. Nisi do wes anderson seitan, banksy sartorial +1 cliche. Iphone scenester tumblr consequat keffiyeh you probably haven't heard of them, sartorial qui hoodie. Leggings labore cillum freegan put a bird on it tempor duis.

    works in modern browsers, regardless of whether text spans only one or multiple lines.

    Also updated the fiddle at http://jsfiddle.net/74Rnq/135/ Not sure what you were doing with a 625px margin on the left when the thing itself was only 150px in width… Tidied things up a bit by removing the inline styling and using a bit of padding as well.

提交回复
热议问题