我有以下内容
<div class="label" style="position: absolute; top: 20px; left: 20px; width: 200px; height: 40px;"> Label Text </div> <div class="label" style="position: absolute; top: 70px; left: 20px; width: 200px; height: 120px;"> Also several lines of Label Text may be included </div>
如何在div.label中垂直对齐(可能是几行)文本?
如果需要,我可以添加innerHTML,但我无法更改容器(class =“label”).
解决方法
你可以使用一些东西
<div class="label" style="position: absolute; top: 70px; left: 20px; width: 200px; height: 120px; display: table; vertical-align: middle; border:1px solid #000"> <span style="display: table-cell;vertical-align: middle;"> Also several lines of Label Text may be included </span>