Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

212
Vistas
Image div overlay and preserving position during resize

I am placing a div on top of an responsive image, like this: enter image description here

When I resize, I lose the position of the div tag, like this: enter image description here

How can I resize this overlay div so that its size is proportionally resized and its position is maintained, when the screen size changes?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Wrap the image in a container with percentage width and create a square using percentage and padding value. After that align the square using position: absolute and percentage value.

.container {
  position: relative;
}

.lotus-image {
  width: 100%;
}

.box {
  position: absolute;
  top: 30%;
  right: 20%;
  width: 30%;
  padding-bottom: 30%;
  border: 4px solid red;
  color: white;
}

.box-content {
  position: absolute;
  width: 100%;
  height: 100%;
  left: 0;
  top: 0;
}
<div class="container">
  <img src = "https://img.freepik.com/free-photo/blossoming-pink-lily-flowers-swamp-natural-background_548832-3024.jpg?size=626&ext=jpg" class="lotus-image" />
  <div class="box">
    <div class="box-content">
      <span>Hello</span>
    </div>
  </div>
</div>

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda