I have a <progress>
element being used as a progress bar. I would like to display some <div>
s on top of the progress bar, but they do not appear. They appear if I use a <div>
(with jQuery-ui progressbar) instead of the <progress>
element, but I would like to avoid this if possible. Does anyone know of a solution?
I have already tried setting z-index: -1
, which did not work.
$(function() {
$("#progressbar").click(function(event) {
var posX = $(this).offset().left;
posX = (event.pageX - posX) / $("#progressbar").width() * 100;
$("#progressbar").val(posX);
})
});
.ball {
background-color: red;
border-radius: 50%;
width: 10px;
height: 10px;
}
#progressbar {
width: 400px;
height: 50px;
position: relative;
}
#left-ball {
position: absolute;
top: calc(50% - 5px);
left: calc(25% - 5px);
}
#right-ball {
position: absolute;
top: calc(50% - 5px);
left: calc(75% - 5px);
}
#line {
position: absolute;
height: 1px;
right: 25%;
background-color: red;
top: 50%;
left: 25%;
}
.delete {
z-index: 10000;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<body>
<progress id="progressbar" value="50" max="100">
<div class="delete ball" id="left-ball"></div>
<div class="delete line" id="line"></div>
<div class="delete ball" id="right-ball"></div>
</progress>
</body>