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

168
Views
HTML2Canvas png colored offsets of divs

I'm coding a sort of UI-displayer for a game, and I want the UI to be downloaded when clicked on a button, i'm using html2canvas for that. The problem is, it shows some big offsets on the image when it gets downloaded.

Result:

result

Expected: (without the background, it doesn't matter).

expected

Here is my code:

function DOWNLOAD() {
    var container = document.getElementById("DrawBox");; /* full page */
    window.scrollTo(0, 0);

    html2canvas(container, {
        allowTaint: true,
    }).then(function(canvas) {

        var link = document.createElement("a");
        document.body.appendChild(link);
        link.download = "html_image.jpg";
        link.href = canvas.toDataURL();
        console.log(container)
        link.target = '_blank';
        link.click();
    });
}

CSS drawbox code (it's a div in my code);

.drawBox {
    position: absolute;
    box - sizing: content - box;
    width: 100 % ;
    height: 500 px;
    margin - top: 20 px;
    width: 800 px;
    box - shadow: 0 0 6 px hsl(200 deg 100 % 80 % );
    margin - left: 200 px;
    text - shadow: 0 0 7 px hsl(200 deg 100 % 80 % );
    background - color: rgb(25, 63, 83, 0.1);
    opacity: 1;
    transition: 1 s;
}

All the created divs are placed in drawBox. Thanks 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!