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

78
Vistas
Set element offset relative to bootstrap modal

I did some research through google and I didn't found anything useful. It's now based by all page offset, but I need that it to be based by modal offset... Image of page

How it supposed to be

My CSS code:

            .bbox {
                cursor: pointer;
                border-style: dashed;
                border-color: red;
                background-color: transparent;
                position: absolute;
            }

My HTML code:

        <div class="modal fade" tabindex="-1" role="dialog" id="correctionModal" aria-hidden="true">
            <div class="modal-dialog modal-lg">
                <div class="modal-content">
                    <div class="modal-body">
                        <div id="limit" style="position: relative;width: 100%; height: auto">
                            <img src="#" id="output-image" class="img-fluid">
                            <div class="bbox" id="eye_1" style="width: 20px; height: 20px;"></div>
                            <div class="bbox" id="eye_2" style="width: 20px; height: 20px;"></div>      
                        </div>              
                        <br>
                        <div class="form-group">
                            <button type="button" class="btn btn-success btn-sm" id="confirmCorrections">Patvirtinti</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>    

My JS code:

            var x_L = x - w_L/2;
            var y_L = y - h_L/2;

            $("#eye_1").height(h_L).width(w_L);
            $("#eye_1").offset({ top: y_L.toFixed(2), left: x_L.toFixed(2) });
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You need to add the offset of your eye boxes onto the offset of their parent element.

Something like this:

var x_L = x - w_L/2;
var y_L = y - h_L/2;
x_L += $("#limit").offset().left;
y_L += $("#limit").offset().top;

$("#eye_1").height(h_L).width(w_L);
$("#eye_1").offset({ top: y_L.toFixed(2), left: x_L.toFixed(2) });
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