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

212
Visualizações
div with flex-grow produces wrong output when converted to base64 image

I have the following html and I'm trying to convert it into a base64 image. But decoding the base64 code produces the wrong image. Here's my code. I need to get the base64 encoding of the image which I need to pass to a PHP variable. Where am I going wrong here? Is there a better way?

CSS:

body {
    color: rgb(0, 0, 0);
    font-family: Helvetica, Arial, sans-serif;
    height: 100%;
    font-size: 14px;
}

div {
    display: block;
}

.divtable {
    border-top: 1px solid #eceff1;
    margin: 0 -16px;
    word-break: break-all;
}

.tablerow {
    border-bottom: 1px solid #eceff1;
    text-decoration: none;
    color: #000;
    display: flex;
}

.tablecol {
    line-height: 1.5em;
    padding: 10px 15px;
    flex: 1;
}

.bar {
    border-radius: 3px;
    background: #eee;
    display: inline-flex;
    width: 100%;
}

.text {
    display: inline-block;
    background: #04b;
    text-align: center;
    font-size: 12px;
    line-height: 18px;
}

.a {
    background: #28EB52;
}
.b {
    background: #F0FF0D;
}

HTML/JS:

<script type="text/javascript" src="https://html2canvas.hertzen.com/dist/html2canvas.min.js"></script>

<div class="divtable">
    <div class="tablerow">
        <div class="tablecol">Label</div>
        <div class="tablecol">
            <div class="bar">
                <div class="text a" style="flex-grow: 8">8</div>
                <div class="text b" style="flex-grow: 15">15</div>
            </div>
        </div>
    </div>
</div>
<script>html2canvas(document.body).then(canvas => {
    console.log(canvas.toDataURL('image/png'));
});</script>
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