I am trying to “push” all the progress bars to the right while centering them vertically so that it looks like this:
I’ve tried giving using inline-block with the first-bar class and giving it a width which works, but my progress bars wont center vertically with the text if I do it that way.
.first-bar {
display: flex;
align-items: center;
}
<div class="software-info">
<h3>Software</h3>
<div class="first-bar">
<span>Indesign CC</span>
<progress value="100" max="100"></progress>
</div>
<div class="first-bar">
<span>Illustrator CC</span>
<progress value="90" max="100"></progress>
</div>
<div class="first-bar">
<span>Photoshop CC</span>
<progress value="80" max="100"></progress>
</div>
<div class="first-bar">
<span>Illustrator CC</span>
<progress value="70" max="100"></progress>
</div>
<div class="first-bar">
<span>HTML 5</span>
<progress value="60" max="100"></progress>
</div>
<div class="first-bar">
<span>CSS 3</span>
<progress value="50" max="100"></progress>
</div>
</div>
2
Answers
You can give the
span
a width value.Just simply set
width
ormin-width
to the<span>
, or the flexbox wayflex
orflex-basic
with a value that can hold all text without wrapping.Alternatively, you can use CSS table layout (added a wrapper div
first-bars
), all cells in the same column will be equal width automatically, therefore no fixed width value is needed.The inline block approach also works, you just need to set
vertical-align: middle;
to reset the default valuebaseline
.