Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html div中的垂直文本中心_Html_Css - Fatal编程技术网

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; 
   }