JSFiddle - React, Tailwind, and code Playground
HTML
<div class="container">
<img src="//placehold.it/800x1300" class="img-responsive centered" />
<div class="img-wrapper centered">
<div class="point" style="bottom: 0%; right: 0%;"></div>
<div class="point" style="top: 0%; right: 0%;"></div>
<div class="point" style="top: 0%; left: 0%;"></div>
<div class="point" style="bottom: 0%; left: 0%;"></div>
</div>
</div>
CSS
html, body {
height: 100%;
}
.container {
position: relative;
width: 100%;
height: 100%;
background: red;
}
.centered {
position:absolute;
max-width: 100%;
max-height: 100%;
right: 0%;
top: 50%;
transform: translateY(-50%);
}
.img-responsive {
position: absolute;
width: auto;
height: auto;
}
.img-wrapper {
max-height: 100%;
max-width: 100%;
}
.point {
background: green;
width: 6px;
height: 6px;
margin-left: -3px;
margin-top: -3px;
position: absolute;
}
JavaScript
//For better performance, use some of the plugins here: http://stackoverflow.com/questions/10086693/jquery-resize-on-div-element
var img = $("img.img-responsive");
$(window).resize(function () {
var wrapperImg = img.parent().find(".img-wrapper");
if (img.width() !== wrapperImg.width() && img.height() !== wrapperImg.height()) {
wrapperImg.width(img.width());
wrapperImg.height(img.height());
}
});
//http://stackoverflow.com/questions/3588102/jquery-load-not-working-on-my-image#answer-3590761
img.one('load', function () {
$(this).parent().find(".img-wrapper").css({
"max-width": this.naturalWidth + "px",
"max-height": this.naturalHeight + "px",
"width": this.width + "px",
"height": this.height + "px"
});
}).each(function () {
if (this.complete) $(this).load();
});