JSFiddle - React, Tailwind, and code Playground
HTML
<div class="el">
<div class="el__content">
<img src="https://www.fillmurray.com/640/360" alt="">
</div>
</div>
<br>
<br>
<br>
<div class="el el--type-2">
<div class="el__content">
<img src="https://www.fillmurray.com/240/560" alt="">
</div>
</div>
<br>
<br>
<br>
<div class="el">
<div class="el__content">
<img src="https://www.fillmurray.com/440/560" alt="">
</div>
</div>
CSS
*,
:before,
:after {
box-sizing: border-box;
}
img {
max-width: 100%;
height: auto;
vertical-align: middle;
}
.el {
position: relative;
max-width: 300px;
/* Просто для примера, чтобы элемент не был огромным */
}
.el:before {
content: '';
position: absolute;
z-index: 1;
top: 0;
left: 0;
right: 20%;
bottom: 0;
background: blue;
}
.el.el--type-2:before {
content: '';
position: absolute;
z-index: 1;
top: 0;
left: 0;
right: 0;
bottom: 50%;
background: blue;
}
.el__content {
position: relative;
z-index: 2;
padding: 20% 0 7.5% 15%;
}
.el.el--type-2 .el__content {
padding: 20% 20% 0 0;
}