JSFiddle - React, Tailwind, and code Playground
HTML
<input type='range' min='0' max='100' value='100' style='width:250px' id='bar'><span id='valeurBar'>100%</span>
<div id="bg"></div>
CSS
.centrer {
display: block;
margin: auto;
/* position: absolute; */
top: 0; bottom: 0; left: 0; right: 0;
height : 250px;
width : 500px;
text-align : center;
position:relative;
}
.container:before {
content: "";
display: inline-block;
vertical-align: middle;
height: 100%;
}
.container {
position:absolute !important;
border:3px solid black;
background: blue;
}
.inner {
display: inline-block;
vertical-align: middle;
text-align:center;
width:100%;
}
.centrerTitre{
font-size: 25;
font-weight: bold;
color : white;
margin : auto;
text-align : center;
padding-left : 4px;
padding-right : 4px;
}
.image-background{
position:absolute;
background: url("https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRCbA4ze7ExrnpgnTxMSBiifLg_TLz3HRLycnlmTWHkvMwcY5X2nZrI_w");
}
JavaScript
var bg = document.getElementById('bg');
bg.className = "centrer";
bg.style.backgroundColor = "blue";
var imageBackground = document.createElement("div");
imageBackground.className = 'image-background';
imageBackground.style.height = '100%';
imageBackground.style.width = '100%';
bg.appendChild(imageBackground);
var container = document.createElement("div");
container.className = 'container';
container.style.height = '100px';
container.style.width = '110px';
var inner = document.createElement("div");
inner.className = 'inner';
var title = document.createElement("p");
title.textContent = "Test";
title.className = 'centrerTitre';
title.style.color = 'black';
inner.appendChild(title);
container.appendChild(inner);
bg.appendChild(container);
document.getElementById('bar').addEventListener("change", function(){
imageBackground.style.opacity = this.value/100;
document.getElementById('valeurBar').innerHTML = this.value + "%";
}, false);