Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

249
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda