【问题标题】:Bootstrap - place progress bar value on right sideBootstrap - 将进度条值放在右侧
【发布时间】:2016-09-01 19:28:43
【问题描述】:

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

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

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

【问题讨论】:

  • 需要上下文代码?

标签: twitter-bootstrap css progress-bar


【解决方案1】:

我会使用 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

【讨论】:

  • 感谢分享。它工作正常。但是,我面临一个场景,我有一张桌子,我试图显示 2 个进度条。在这种情况下,它们都缩小了尺寸。 :(
【解决方案2】:

这将是一种方式。您需要进一步设置样式以使其与您提供的图片相似。

.progress-bar span{
    text-indent: 420px;
    position: absolute;
    color: black;
}
.progress {
    width: 400px;
}
<div class="progress">
   <div class="progress-bar" role="progressbar" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100" style="width: 50%;">
       <span class="show">50% Complete</span>
   </div>
</div>

【讨论】:

    【解决方案3】:

    我希望这段代码对你有用。试试这个代码。这段代码对我有用。

    快乐编码 :-) ;-)

    <!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>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-03
      • 2023-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多