问题
I am working on creating a progress meter that comes from the bottom up using only HTML and CSS. The problem I am facing is that the overlayed image doesn't line up where it belongs. Could someone please help me out?
Edit
Here is the code:
<h2>Fall Fest Candy Collection</h2>
<p>The Fall Fest candy collection has begun! Follow along with the progress bar as we attempt to reach our goal of one million pieces of candy!</p>
<p> </p>
<div id="progress-bar">
<div id="progress-level" style="height: 79%; bottom: 0px; text-align: center;"></div>
</div>
<p style="margin-bottom: 15px; text-align: center;">79% collected</p>
<p> </p>
回答1:
- On
#progress-bar
, setposition: relative
. - On
#progress-level
, removemargin-top: 133px
and addbottom: 0
. Then, change theheight
to a higher number, say50%
, so that you can see it working.

回答2:
I fixed with:
<div id="progress-level" style="height: 7%; margin-top: 76px; text-align: center;"></div>
Changed the top margin to 76px. That was in Chrome's developer tools.
回答3:
I would try using position:relative and bottom properties to move the #progress-level up, but I can't try it out now, I am on a mobile device ;-) .
来源:https://stackoverflow.com/questions/7698804/vertical-css-progress-bar