How to create responsive Facebook like cover photo where the image should always maintain the top position, not stretched and being cut? I tried to inspect the codes of Facebook Cover Photo but I still can't understand how it works. I've provided sample images on what I need to achieve.
These images are my current progress
These are my sample codes
HTML:
<div>
<img src="onepiece.jpg" />
</div>
CSS:
div{
max-width: 1024px;
width: 100%;
margin: 0 auto;
height: 270px;
position: relative;
display: block;
z-index: 1;
overflow: hidden;
margin-top: 5px;
max-height: 100%;
}
img{
width: 100%;
height: auto;
position: absolute;
top: -134px;
}