繁体   English   中英

如何在同一行上获得多个具有不同ID的进度条?

[英]How can I get multiple progress bars with different ID's on the same line?

我有一个Bootstrap进度条,它显示用户的熟练程度(基本上是对尝试的正确响应)。 但是,我想用两根色条给差异上色,一个标为“ bg-success”,另一个标为“ bg-warning”,以使对比度更加明显。 我使用具有不同ID的进度条来完成此操作。 问题在于进度条不会出现在同一行上。

下面的代码显示了我的位置,并且尝试了所有可以修复的重新标记尝试,但均无济于事。

以下是相关的JavaScript:

function setBars() {
  var profPerc = Number(((myProg[1] / myProg[2]) * 100).toFixed(csvSize.toString().length));
  document.getElementById("profBar").innerHTML = "<strong>" + profPerc.toString() + "</strong>";
  document.getElementById("profBar").style.width = profPerc + "%";
  document.getElementById("offBar").innerHTML = "<strong>&nbsp;</strong>";
  document.getElementById("offBar").style.width = (100 - profPerc) + "%";
}

// There are no errors with any of the other above-mentioned variables.

以下是相关的HTML:

<div class="proficiencydiv">
  <div class="progress-bar bg-success" role="progressbar" id="profBar" aria-valuemin="0" aria-valuemax="100"></div>
  <div class="progress-bar bg-warning" role="progressbar" id="offBar" aria-valuemin="0" aria-valuemax="100"></div>
</div>

我期望结果如下所示:

"[profBar][offBar]".

相反,我得到:

"[profBar]"

"[offBar]"

在css下面添加

.proficiencydiv{
    display: flex}

 .proficiencydiv{ display: flex} .proficiencydiv div{ margin: 10px} 
 <div class="proficiencydiv"> <div class="progress-bar bg-success" role="progressbar" id="profBar" aria-valuemin="0" aria-valuemax="100">profBar</div> <div class="progress-bar bg-warning" role="progressbar" id="offBar" aria-valuemin="0" aria-valuemax="100">offBar</div> </div> 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM