Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

248
Views
How to create a Facebook like Cover Photo Responsive UI

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.

Desktop Image

Tablet View

Mobile View

These images are my current progress

Desktop View

Tablet View

Mobile View

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;
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try utilizing object-fit to keep the image the correct dimensions within an area, similar to when using an image in background-image CSS. The media queries I added are to adjust the size of the image container on the screen sizes from your screenshots.

div.img-container {
  max-width: 1024px;
  width: 100%;
  margin: 0 auto;
  height: 150px;
  position: relative;
  display: block;
  z-index: 1;
  overflow: hidden;
  margin-top: 5px;
  max-height: 100%;
}

img {
  width: 100%;
  object-fit: cover;
  object-position: center top;
}

@media (min-width: 576px) {
  div.img-container {
    height: 225px;
  }
}

@media (min-width: 768px) {
  div.img-container {
    height: 270px;
  }
}
<div class="img-container">
  <img src="https://www.animationmagazine.net/wordpress/wp-content/uploads/One-Piece-1000-Commemorative-Battle-of-Onigashima-Visual-1000x600.jpg" />
</div>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!