I am trying to achieve UI as shown in the image. However I am having little hard time after trying combinations of positioning now I am clueless. Can someone help me with th
.progress{
position:relative;
width:500px;
border:1px solid #333;
position:relative;
padding:3px;
}
.bar{
background-color:#00ff00;
width:50%;
height:20px;
transition:width 150ms;
}
.percent{
position:absolute;
display:inline-block;
top:3px;
left:50%;
transform:translateX(-50%);
}
<div class="progress">
<div class="bar"></div >
<div class="percent">50%</div >
</div>
interactive demo at http://jsfiddle.net/gaby/Zfzva/
Take this example....
HTML CODE:
<div id="progressbar" style="height:25px;">
<span class="text"></span>
</div>
CSS
.text {
color: black;
margin-left: 130px;
position: absolute;
}
JQUERY:
$( "#progressbar" ).progressbar({
value: some_Value;
});
$("#progressbar span.text").text(some_Value + "%");
To change % dynamically here is code
HTML
<div class="progress">
<span class="percent">{{currentTimer}}</span>
<div class="bar" [style.width]="progress + '%'"></div>
<span class="duration">{{duration}}</span>
</div>
CSS
.progress {
width: 100%;
// border: 1px solid black;
position: relative;
padding: 0px;
}
.percent {
position: absolute;
left: 0%;
}
.bar {
height: 16px;
background-color: rgb(41, 49, 32);
}
.duration {
position: absolute;
left: 90%;
top:-5%
}
<style>
.progress{
position:relative;
width:500px;
height:30px;
border:1px solid #000;
}
.bar{
//Change width with javascript
position:absolute;
top:0px; left:0px;
background:#0F3;
max-width:500px;
height:30px;
}
.percent{
position:relative;
width:100%;
text-align:center;
font-size:18px;
padding:10px;
}
</style>
<div class="progress">
<div class="percent"><span>50%</span><div class="bar"></div></div>
</div>
You'll have to play around with the font-size and padding to get it just right, but that should about do it.
i had the same problem and developed this:
http://jsfiddle.net/DgXM6/2/
HTML:
<div class="noload">
<span class="loadtext">40%</span>
<div class="load"></div>
</div>
CSS:
.load{
width: 50%;
height: 12px;
background: url( data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAALCAYAAAC+jufvAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwAAADsABataJCQAAABp0RVh0U29mdHdhcmUAUGFpbnQuTkVUIHYzLjUuMTAw9HKhAAAAPklEQVQYV2M48Gvvf4ZDv/b9Z9j7Fcha827Df4alr1b9Z1j4YsV/BuML3v8ZTC/7/GcwuwokrG4DCceH/v8Bs2Ef1StO/o0AAAAASUVORK5CYII=);
-moz-border-radius: 4px;
border-radius: 4px;
}
.noload{
width: 100px;
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAALCAYAAAC+jufvAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwAAADsABataJCQAAABp0RVh0U29mdHdhcmUAUGFpbnQuTkVUIHYzLjUuMTAw9HKhAAAANUlEQVQYVy3EIQ4AQQgEwfn/zwghCMwGh8Tj+8yVKN0d2l00M6i70XsPmdmfu6OIQJmJqooPOu8mqi//WKcAAAAASUVORK5CYII=);
-moz-border-radius: 4px;
border-radius: 4px;
border: 1px solid #999999;
position: relative;
}
.loadtext {
font-family: Consolas;
font-size: 11px;
color: #000000;
position: absolute;
bottom: -1px;
left: 45%;
}
I did half the work for you.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<style type="text/css">
#container { width:350px; }
#main_bar {
width:374px;
height:35px;
border:1px solid #111;
}
#inner_bar {
float;left;
width:150px;
background:#00ff00;
margin:-20px 0 0 5px;
}
p {
margin-top:-33px;
text-align:center; }
</style>
<title>The document title</title>
</head>
<body>
<div id="container">
<div id="main_bar">
</div><!--#main_bar-->
<div id="inner_bar">
<p>hello</p>
</div><!--#inner_bar-->
<p>30%</p>
</div>
</body>
</html>
You can mess with the widths, margins, paddings! I got lazy, and didn't want to finish it. lol