我有一个<div>
包含文本的元素,我想对齐此<div>
垂直中心的内容。
这是我的<div>
风格:
#box {
height: 170px;
width: 270px;
background: #000;
font-size: 48px;
color: #FFF;
text-align: center;
}
<div id="box">
Lorem ipsum dolor sit
</div>
解决方案:
您可以尝试以下基本方法:
div {
height: 100px;
line-height: 100px;
text-align: center;
border: 2px dashed #f69c55;
}
<div>
Hello World!
</div>