Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

169
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda