I am trying a very simple project item-list/progress display (non-interactive, just a static display) which intends to show various categories overlaid as progress boxes, like so:
.plan {
list-style: none;
}
.plan li {
display: block;
}
.progress a {
text-decoration: none;
}
.plan .subject {
}
.plan .progress {
background-color: #eee;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25) inset;
border-radius: 8px;
margin-bottom: 1ex;
position: relative;
display: inline-block;
}
.progress span {
height: 100%;
border-radius: 8px 0 0 8px;
display: inline-block;
}
.progress a {
padding: 2px 1ex;
display: inline-block;
}
.progress .done {
background-color: lightgreen;
}
.progress .critical {
background-color: crimson;
}
.progress .todo {
background-color: cyan;
}
<ul class="plan">
<li>
<div class="progress">
<span class="done" style="width: 55%"/>
<span class="todo" style="width: 35%"/>
<span class="critical" style="width: 25%"/>
<a href=".">1234567</a>
</div>
<span class="subject"> lorem ipsum dolor sit amet </span>
</li>
<li>
<div class="progress">
<span class="done" style="width: 80%"/>
<span class="todo" style="width: 50%"/>
<a href=".">8901234</a>
</div>
<span class="subject"> phasellus elit orci, suscipit et eros eu, consequat viverra sem. </span>
</li>
</ul>
In the above example, my intention is to set width of the nested span
elements of div.progress
, to be the percentage of the div.progress
box size itself. However, as can be seen in the output, successive span
s set their width to the percentage of their preceding sibling.
E.g. in the first item the 55%
is that of the id box, as intended. The following 35%
is that of the 55%
which is .55*.35 = 19.25%
of the id box), and the third 25%
width is .1925*.25=~5%
of the id box.
How can I get the sibling span to be the percentage of the parent div?
Alternative layout suggestions would be very much appreciated. The objective here is to display individual sub-categories (e.g. critical
, todo
, done
) as a percentage of a total, whose size is based on the item they overlay (here the <a>
element with the item id). For example, they could've been sized as individual boxes which would line up as, 25%
, 10%
, and 20%
and remainder 45%
(gray) as default, respectively for the first item.