Html div中的垂直文本中心
在这里,您可以显示我的代码示例:Html div中的垂直文本中心,html,css,Html,Css,在这里,您可以显示我的代码示例: 如何在div progressBarText中垂直居中显示文本?将行高添加到文本中 试试这个: .progressBarText{ position:absolute; z-index:10; top:0; left:0; width:100%; line-height:15px; text-align:left; color: white;
如何在div progressBarText中垂直居中显示文本?将
行高添加到文本中
试试这个:
.progressBarText{
position:absolute;
z-index:10;
top:0;
left:0;
width:100%;
line-height:15px;
text-align:left;
color: white;
}
哦,是的,这很简单。。谢谢如果你的方式不是正确的,但不是荒谬的,那么没有必要否决正确的答案。我认为我的答案是正确的@crush@AlessandroMinoccheri你的答案不对。尝试调整字体大小,看看“垂直居中”文本会发生什么情况。该解决方案适用于OP示例,但未指定该解决方案是适用于所有现有字体大小的全局解决方案,不是吗?我再说一遍,你的反对票是没有必要的,你的批评者对这个问题也没有建设性@crush@AlessandroMinoccheri你的答案不对。时期
#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;}
.progressBarText{
position:absolute;
z-index:10;
top:0;
left:0;
width:100%;
line-height:15px;
text-align:left;
color: white;
}