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

234
Vistas
How to make an icon overlay an Image such that the icon remains in its place when the image is uploaded via javascript?

I'm trying to create an app that has a feature that allows its users to upload images from their computer and that chosen image is displayed as preview. The problem I'm running into is that before the image is selected, an icon button is overlaid on the bottom-right of the image element and when the image is chosen the icon button is pushed off the image element. I want the icon button to stay in its place.

Here's the code pertaining to this part:

<div id="main-container">
     <section id="customer_archetype" style="width: 500px; margin: auto">
         <form method="post" action="./submit_form_data.php" style="display: flex; flex-direction: column;">
           <div style="margin: auto;">
              <div style="width: 150px; height: 150px; background-color: #E1E0E1; border-radius: 100px; ">
                   <img id= "uploaded_image" src="#" style="display:none; width: 150px; height: 150px; border-radius: 100px;" >
                   <input style="display:none" name = "archetype_image_input" id="archetype_image_input" type="file" accept="image/*">
                   <img src="./images/camera.png" id="cam_img" style="width:22px; height:22px; color:gray; z-index = 1; cursor: pointer ; margin-left:105px; margin-top: 125px;">
               </div>
              </div>    
              <div id = "input_fields" style="display: flex; flex-direction: column; margin: 10px auto; width: 400px;">
           </div>
         </form>
         <div style="text-align: center;">
             <button style="width: 100px" id="add-input-field-btn">Add Field</button>
             <button id="remove-input-field-btn">Remove Field</button>
         </div>
     </section>
</div>

The code that I have written for the image and icon button

And here's the look of the output before the image is chosen:

Picture of output before image is chosen

Output after image is chosen. As you can see the icon is pushed off:

Output after image is chosen

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

0

You need to set the image container as position: relative and then with the icon (the camera image), set it to be position: absolute.

Don't use margin properties to place an image like this, it's subject to move as the DOM is changed.

Here's a working example using your code. I've added classes to make viewing the styling easier.

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