Simple chart - CSS
by cillay
HTML
<div class="chart">
<label>Celery</label>
<label>Apples</label>
<label>Walnuts</label>
<label>Grapes</label>
<div class="graph">
<p></p><p></p><p></p><p></p>
</div>
</div>
CSS
div.chart {
width: 500px;
height: 150px;
position: relative;
top: 0;
left: 0;
}
div.graph {
width: 450px;
height: 150px;
position: relative;
top: 0;
left: 40px;
border: 1px solid black;
}
div.graph > p {
display: block;
height: 30px;
position: absolute;
left: 0;
border: 1px solid black;
}
div.graph > p {
top: 0;
margin: 0;
padding: 0;
width: 300px;
background-color: rgb(0,255,0);
}
div.graph > p + p {
top: 40px;
width: 250px;
background-color: rgb(255,0,0);
}
div.graph > p + p + p {
top: 80px;
width: 330px;
background-color: rgb(255,255,0);
}
div.graph > p + p + p + p {
top: 120px;
width: 190px;
background-color: rgb(255,0,255);
}
div.chart > label {
position: absolute;
width: 40px;
font: normal 10px Arial, Helvetica;
}
div.chart > label {
top: 10px;
}
div.chart > label + label {
top: 50px;
}
div.chart > label + label + label {
top: 90px;
}
div.chart > label + label + label + label {
top: 130px;
}