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

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

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 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