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

121
Vistas
Draw Rectangle with respect to screen/viewport on canvas having object-fit: cover

In html page, mainly three elements are present those are canvas,video, div.

Below is the css for same.

#myCanvas
{
    position: absolute;
    height: 100%;
    width: 100%;
    top: 0px;
    object-fit: cover;
}

#myVideo
{
    padding: 0;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    -webkit-transform: scaleX(-1);
    transform: scaleX(-1);
    display:none;
}

#divRectArea
{
    position: fixed;
    border: solid 5px blue;
    top:79%;
    left:72%;
    width: 24%;
    height: 15%;
}

In javascript, we are drawing video on canvas.

The width and height of canvas & video set to 1080, 1920 respectively via javascript .

Due to object-fit: cover, canvas is getting stretched to entire screen (viewport) [without maintaining aspect ratio].

Note that div (divRectArea) has position as fixed in css.

I want to draw reactangle exactly at same location where div is placed,

How to achieve this ?

Thank you in advance.

about 4 years ago · Juan Pablo Isaza
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