如何使用CSS将文本垂直居中? [重复]

帅比萌擦擦* 提交于 2020-08-18 03:33:08

问题:

This question already has an answer here: 这个问题已经在这里有了答案:

I have a div element which contains text, and I want to align the contents of this div vertically center. 我有一个包含文本的div元素,并且我想将此div的内容垂直居中对齐。

Here is my div style: 这是我的div样式:

#box { height: 170px; width: 270px; background: #000; font-size: 48px; color: #FFF; text-align: center; }
<div id="box"> Lorem ipsum dolor sit </div>

What is the best way to do this? 做这个的最好方式是什么?


解决方案:

参考一: https://stackoom.com/question/bCJG/如何使用CSS将文本垂直居中-重复
参考二: https://oldbug.net/q/bCJG/How-do-I-vertically-center-text-with-CSS-duplicate
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!