Bootstrap - 将进度条值放在右侧

时间:2016-05-06 16:24:33

标签: css twitter-bootstrap css3 progress-bar

  

我想将Bootstrap进度条值放在右侧的进度条之外。

我没有看到这是可能的,但现在我看到的唯一选项是将进度类设置为100%的宽度减去值文本的宽度。

处理此问题的最佳方法是什么?

My Progress Bar

3 个答案:

答案 0 :(得分:2)

我会使用CSS表来实现

HTML

<div class="progress-custom">
    <div class="progress">
        <div class="progress-bar" role="progressbar" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100" style="width: 50%;"></div>
    </div>
    <div class="progress-value">
        50%
    </div>
</div>

CSS

.progress-custom {
    display: table;
    width: 100%;
    margin-bottom: 20px; /*optionally same as the margin bottom of progress class*/
}

.progress-custom .progress{
    margin-bottom: 0;
    display: table-cell;
    vertical-align: middle;
}

.progress-custom .progress-value{
    display: table-cell;
    vertical-align: middle;
    width: 1%; 
    padding: 0 4px; /*optionally*/
}

你可以看到它here

答案 1 :(得分:0)

这将是一种方式。您需要进一步的样式才能使其与您提供的图像相似。

let result = [{
  id: 1,
  age: 23,
}, {
  id: 1,
  age: 25,
}, {
  id: 2,
  age: 230,
}, {
  id: 2,
  age: 255,
}, {
  id: 3,
  age: 232,
}, {
  id: 1,
  age: 215,
}].sort((a,b) => b.age - a.age)
.filter((row,pos,self) => self.findIndex(item => item.id === row.id) === pos)
.sort((a,b) => a.id - b.id);

document.body.textContent = JSON.stringify(result);
.progress-bar span{
    text-indent: 420px;
    position: absolute;
    color: black;
}
.progress {
    width: 400px;
}

答案 2 :(得分:0)

我希望这段代码对您有用。试试这个代码。这段代码适合我。

快乐编码:-); - )

&#13;
&#13;
<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<style>
.progress{
border-radius: 10px ! important;
}
body{
padding-top: 20px;
}
</style>
<body>

<div class="container-fluid"><!--Container starts-->
<div class="row"><!--Row starts-->
<!--Progress Bar starts-->
<div class="col-xs-5">
  <div class="progress">
    <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100" style="width:50%">
    </div>
  </div>
</div>
<!--Progress Bar ends-->

<!--Percentage starts-->
<div class="col-xs-7">
<div class="pull-left">
50% <!--Add Your Percentage Here Dynamically-->
</div>
</div>
<!--Percentage ends-->

</div><!--Row ends-->
</div><!--Container ends-->

</body>
</html>
&#13;
&#13;
&#13;