您可以在此处展示我的代码示例:Jsfiddle
<div id="gameTimeBar-holder">
<div id="gameTimeBar"></div>
<div class="progressBarText">Actions : 852 minutes</div>
#gameTimeBar-holder{width:200px;height:15px;background:grey; position:absolute; top:45px; left:5px;}
#gameTimeBar{width:0;height:100%;background:purple;}
.progressBarText{position:absolute;z-index:10;top:0;left:0;width:100%;text-align:left; color: white;}
如何在div progressBarText中垂直居中我的文字?
答案 0 :(得分:1)
将line-height
添加到您的文字中
试试这个:
.progressBarText{
position:absolute;
z-index:10;
top:0;
left:0;
width:100%;
line-height:15px;
text-align:left;
color: white;
}