I have a bar graph using html and css, I am using height to show the amount the bar is filled in. Right now it works, but it works in the reverse order than what I want. When height:0% the bar is filled in 100%. I tried changing the CSS to “bottom” instead of “top” but that didn’t do anything. How can I change this so “height:100%” will make it 100% filled in?
html:
<div class="bars">
<div><span style="height:0%;"></span></div>
<div><span style="height:10%;"></span></div>
<div><span style="height:20%;"></span></div>
<div><span style="height:30%;"></span></div>
<div><span style="height:40%;"></span></div>
<div><span style="height:50%;"></span></div>
<div><span style="height:60%;"></span></div>
<div><span style="height:70%;"></span></div>
<div><span style="height:80%;"></span></div>
<div><span style="height:90%;"></span></div>
<div><span style="height:100%;"></span></div>
<div><span style="height:100%;"></span></div>
<div><span style="height:90%;"></span></div>
<div><span style="height:80%;"></span></div>
<div><span style="height:70%;"></span></div>
<div><span style="height:60%;"></span></div>
<div><span style="height:50%;"></span></div>
<div><span style="height:40%;"></span></div>
<div><span style="height:30%;"></span></div>
<div><span style="height:20%;"></span></div>
<div><span style="height:10%;"></span></div>
<div><span style="height:0%;"></span></div>
</div>
CSS:
.bars{
height: 48px;
display: block;
overflow: hidden;
margin: 0 3px;
}
.bars div{
background: rgb(12,88,160); /* Old browsers */
background: -moz-linear-gradient(top, rgba(12,88,160,1) 0%, rgba(10,52,91,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(12,88,160,1)), color-stop(100%,rgba(10,52,91,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(12,88,160,1) 0%,rgba(10,52,91,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(12,88,160,1) 0%,rgba(10,52,91,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(12,88,160,1) 0%,rgba(10,52,91,1) 100%); /* IE10+ */
background: linear-gradient(top, rgba(12,88,160,1) 0%,rgba(10,52,91,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#0c58a0', endColorstr='#0a345b',GradientType=0 ); /* IE6-9 */
float: left;
height: 100%;
width: 8px;
margin-right: 2px;
}
.bars div span {
background: #233243;
height: 0%;
width: 100%;
display: block;
position: relative;
top: 0;
}
Just give the .bars div class “position: absolute;” and change the .bars div span CSS to “position: relative; bottom: 0px;”.
Example here.
CSS: