php - 如何修改进度条的最大值
问题描述
所以,我正在制作一个进度条,它从我声明的一些变量中获取它的值,除了有一个问题外,一切都运行良好。当我的 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>';
?>
我不擅长解释事情,所以我希望你能理解。谢谢。
解决方案
宽度应该是$current_players
除以的百分比$max_players
。它最多只能填充 80%,因为$width
只有 80(玩家),如您链接的图像所示。的计算$width
应该如下:
$width = $current_players / $max_players * 100;
推荐阅读
- c++ - 字符串擦除()给核心转储
- python - Scrapy 使用 FormRequest.from_response 将 pdf 文件上传到特定的表单(id)
- javascript - syntax of vue.js does not work
I want to use this dropdown menue for my webproject based on vue.js. Everything with vue.js worked fine
- javascript - 如何测试简单的中间件
- string - Converting String column to vector in python
- azure - 如何在不明确指定名称的情况下将 json 键值对投影到列
- javascript - converts to double array after declaring req.body
- c - insert blob into sqlite 3 with C
- r - 在 R 中对可变数量的列进行排序
- python - How to cluster data with user_id - k-means algorithm