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

105
Views
html2canvas captures only background

I'm trying to capture a screenshot using html2canvas. But it creates only the background.

I think it is because I am using linear-gradient for background and -webkit-background-clip.

How can I take a proper screenshot?

<style>
@import url('https://fonts.googleapis.com/css?family=Monoton');
    html, body {
        width: 100%;
        height: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
        font-family: "Monoton", Helvetica, sans-serif;
        letter-spacing: 5px;
        text-align:center;
    }
    .container {
        background: #ab3428;
        display: flex;
        justify-content: center;
        align-items: center;
        width: 200px;
        height: 200px;
        padding: 20px;
    }
    h1 {
        display: inline;
        font-size: 20px;
        line-height:1.5;
        color: #000000;
        color: transparent;
        background: linear-gradient(7deg, #f5ee9e 50%, #000000 0);
        -webkit-background-clip: text;
    }
  
  #btnSave{
    text-align: center;
    position: fixed;
    top: 0;
    width: 150px;
    z-index: 100;
}

.download-btn{
    font-size: 12px;
    padding: 5px;
    border: 2px solid rgb(33, 33, 33);
    margin: 10px; 
}


</style>
<button class="download-btn" id="btnSave">Download Image</button>
        
<div class="container">
    <h1>TEST</h1> 
</div>
<div id="img-out"></div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.3.2/html2canvas.min.js" integrity="sha512-tVYBzEItJit9HXaWTPo8vveXlkK62LbA+wez9IgzjTmFNLMBO1BEYladBw2wnM3YURZSMUyhayPCoLtjGh84NQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.5/FileSaver.min.js" integrity="sha512-Qlv6VSKh1gDKGoJbnyA5RMXYcvnpIqhO++MhIM2fStMcGT9i2T//tSwYFlcyoRRDcDZ+TYHpH8azBBCyhpSeqw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script>

$(function () {
    $("#btnSave").click(function () {
        window.scrollTo(0, 0);
        html2canvas($(".container")[0]).then(function (canvas) {
        $("#img-out").append(canvas);
     
       });
    });
 });
</script>

enter image description here

This is my jsfiddle link: https://jsfiddle.net/shinokada/cxnh81f4/55/

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!