To Solve this issue better to use javascript library imageScale();
Different options available in this(fill, best-fill, best-fit, best-fit-down).
You have to just include js file. then after using the following format for the image.
<div class="image-container">
<img class="scale" data-scale="best-fit-down" data-align="center" src="https://wordpress.stackexchange.com/questions/300845/img/example.jpg">
</div>
Now add this JavaScript code to your page.
$(function() {
$("img.scale").imageScale();
});
The second option is to use another javascript imagefill.
<div class="container">
<img src="https://wordpress.stackexchange.com/questions/300845/myawesomeimage" />
</div>
$('.container').imagefill();
// image stretches to fill container
for more imageScale | imageFill