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

122
Vistas
Blindside the Borg queen: Image with overlaying element that is absolute positioned above the same area of the image when the image rescales

Sorry if this is not the right way to do it, please feel free to suggest other solutions. I don't care what the text or the blindfolding element is as long as it servers the purpose. Maybe it is possible to do this with an svg but it is way too advanced for me.
I am trying to create a page showing an image with a certain area covered so that the reader can't see it. Here is my code so far. Not sure how to calculate/recalculate the position of that element based on the new position and size of the picture when the browser window resizes https://jsfiddle.net/xay5u78s/

    <html lang="en">
<head>
  <title>Bootstrap Responsive image example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
  </head>
  <body>

    <div >
        <div >
            <img src="https://upload.wikimedia.org/wikipedia/en/b/bc/Borg_Queen_2372.jpg" class="img-fluid"  style="width:30%" alt="image">
            <div class="position-absolute" style="height:30px; background-color: white; top: 25%;left: 13%;"> Covered covered </div>
        </div>
        
    </div>

</body>  
</html>

Desired effect enter image description here enter image description here

Updated fiddle with the solution as suggested by @quentin
https://jsfiddle.net/xay5u78s/1/

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

0

Absolutely positioned elements are positioned with respect to the edges of the nearest ancestor element that is positioned (meaning "Has position: anything-but-static").

So set the containing div to position: relative and give it the same dimensions as the image.

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