I am working on making an image responsive using HTML and CSS. My goal is to have the right side of the image crop as the screen size decreases to maintain the height and position of the image, similar to Nike's hero image. I want to keep the white space on the left and right sides of the image intact when resizing the screen. How can I achieve this effect? Here is a snippet of my code:
.hero {
position: relative;
text-align: center;
top: 6.7rem;
width: 100%;
}
.hero>img {
width: 100%;
max-width: 1330px;
height: 690px;
object-fit: cover;
}
<div class="hero">
<img src="https://static.nike.com/a/images/q_auto:eco/t_product_v1/f_auto/dpr_2.0/w_441,c_limit/9d1635ed-eed0-45b0-b34d-e00468e2f79e/tanjun-easyon-shoes-mplG1H.png" alt="">
</div>