首页 > 解决方案 > 如何修改进度条的最大值

问题描述

所以,我正在制作一个进度条,它从我声明的一些变量中获取它的值,除了有一个问题外,一切都运行良好。当我的 aria-value 现在满足我的 aria-value max 时,进度条中仍有剩余空间,因为它将其宽度填充到仅 80% 而不是 100%。所以我有点坚持解决这个问题。这是我的代码

 <?php 
      $current_players=$infosprp['players'];
      $max_players=$infosprp['places'];
      $width = $current_players;

      echo '<div class="progress w-25 m-auto" style="height: 30px;">
      <div class="font-weight-bold progress-bar bg-warning progress-bar-striped progress-bar-animated text-center" 
           role="progressbar" 
           aria-valuenow="'.$current_players.'"
           aria-valuemin="0" 
           aria-valuemax="'.$max_players.'"style="width:'.$width.'%;font-size:18px;">
           '.$width.'/'.$max_players.'
      </div>
    </div>'; 
?>

这是填充进度条时的结果图片

我不擅长解释事情,所以我希望你能理解。谢谢。

标签: phphtmlcssbootstrap-4

解决方案


宽度应该是$current_players除以的百分比$max_players。它最多只能填充 80%,因为$width只有 80(玩家),如您链接的图像所示。的计算$width应该如下:

$width = $current_players / $max_players * 100;

推荐阅读