I am having a problem with bootstrap’s progress bar. The span text I want displayed inside is only showing the bottom half and I can’t figure out why.
I am doing a code along with my course and I have checked it thoroughly and can’t see any difference in the code.
Our IDEs are different. He’s using cloud9 and I am using codeanywhere. I wouldn’t have thought that would matter.
I tried to continue with the code along and add CSS thinking it might sort it out. But the problem persisted
Code Snippet
.progress {
position: relative;
height: 25px;
margin-bottom: 4px;
}
.progress-type {
position: absolute;
left: 0px;
font-weight: 400;
padding: 3px 30px 2px 10px;
color: #fafafa;
background-color: rgba(25, 25, 25, 0.2);
}
<div class="row">
<div class="col">
<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="90" aria-valuemin="0" aria-valuemax="100" style="width:90%;">
<span class="sr-only">90% Complete</span>
</div>
<span class="progress-type">HTML / HTML5</span>
</div>
</div>
</div>
<!-- Bootstrap 5.3 -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
2
Answers
It works if I override Bootstrap and force the height using
!important
.This isn’t a Bootstrap or height problem. It’s a matter of how you’re centering your absolutely positioned element. (The parent of such an element does not expand to contain it, per HTML spec.) Use a more standard method for that (not padding) and it’s fine.
How to center div vertically inside of absolutely positioned parent div