Reputation: 360
I want to make the Bootstrap progress bar value placed outside of the progress bar to the right.
I don't see this being possible but right now the only option I see is to set progress class a width of 100% minus the width of the value text.
What would be the best way to handle this?
Upvotes: 7
Views: 8858
Reputation: 20383
I would use CSS tables to achieve that
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*/
}
You can see it here
Upvotes: 3
Reputation: 65
This would be a way. You need further styling to make it resemble te image you provided.
.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>
Upvotes: 0
Reputation: 308
I hope this code will work for you. Try this code. This code works for me.
Happy Coding :-) ;-)
<!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>
Upvotes: 0