Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

118
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!