div中多行文本自适应垂直居中

方法一
父元素display为table时子元素display:table-cell才生效

你好
.text > div { display: table; width: 100%; height: 100% } .text > div > div { display: table-cell; width: 100%; height: 100%; vertical-align: middle; }
方法二




菜鸟教程(runoob.com)




Center me!Center me!Center me!Center me!Center me!

注意: Flexible boxes 在 IE 9和更早版本的浏览器中不兼容

 





 

你可能感兴趣的:(div中多行文本自适应垂直居中)