JSFiddle - React, Tailwind, and code Playground
HTML
<div class = "container"><img src = "http://fc06.deviantart.net/fs50/f/2009/325/9/e/Super_Mario_Bros__Background_by_Hyp64.png" class = "image"/>
<div id = "blockpercentage"></div>
</div>
<div id="blockpx">
CSS
html, body {
width: 100%;
height: 100%;
margin: 0;
}
.wrapper {
width: 100%;
height: 100%;
}
.container {
position: relative;
}
img {
height: 100%;
}
#background {
height: 100%;
position: absolute;
z-index: 0;
background: url('');
}
#blockpx {
position: absolute;
left: 148px;
bottom: 146px;
height: 14px;
width: 54px;
background-color: black;
}
#blockpercentage {
position: absolute;
height: 3.2%;
bottom: 28%;
left: 25%;
width: 10%;
background-color: red;
}
JavaScript
$(document).ready(function(){
$(".container").css("width", $(".image").width());
$(window).resize(function(){
$(".container").css("width", $(".image").width());
});
});