JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js"></script>
<div id="ub-story-maker">
<div class="outer">
<div id="imagewrap" class="wrap">
<div id="ub-type-wrap">
<h3 class="desc">What's up?</h3>
<textarea id="ub-user-txt" oninput="this.style.height = "";this.style.height = this.scrollHeight + "px"" maxlength="80" placeholder="Type something here"></textarea>
</div>
<img class="ub-user-bg-img" src="https://i.imgur.com/I5QcsqI.jpg">
</div>
</div>
<div id="canvasWrapper" class="outer">
</div>
<a id="downloadLink" src="#" download="UB22-izjava.png">Download</a>
</div>
CSS
.outer, .wrap, .html2canvas, .image_text {
display: inline-block;
vertical-align: top;
}
.wrap {
text-align: center;
}
#imagewrap {
width: 100%;
}
#ub-story-maker {
max-width: 500px;
}
.outer {
position: relative;
width: 100%;
}
#ub-type-wrap {
position: absolute;
}
#ub-type-wrap {
position: absolute;
left: 0;
right: 0;
height: 30%;
bottom: 13%;
display: -webkit-box;
display: -moz-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
-moz-justify-content: center;
-webkit-justify-content: center;
-ms-justify-content: center;
justify-content: center;
}
h3 {
font-family: 'adineue PRO Cond';
font-size: 42px;
color: #fff;
margin: 0;
text-align: center;
}
#ub-user-txt {
font-family: 'KG Seven Sixteen';
font-size: 38px;
text-align: center;
color: #fff !important;
background: transparent;
line-height: 42px;
margin: -17px auto 0;
border: none;
outline: none;
overflow: hidden;
resize: none;
}
#ub-user-txt::-webkit-input-placeholder {
color: #fff;
}
#ub-user-txt:-moz-placeholder {
color: #fff;
}
#ub-user-txt::-moz-placeholder {
color: #fff;
}
#ub-user-txt:-ms-input-placeholder {
color: #fff;
}
#ub-user-txt::placeholder {
color: #fff;
}
.ub-user-bg-img {
width: 100%;
}
#downloadLink {
background: #000;
color: #fff;
display: table;
margin: auto;
font-family: 'AdihausDIN';
font-size: 20px;
line-height: 20px;
font-weight: bold;
padding: 13px 30px 8px;
text-transform: uppercase;
max-width: 200px;
text-align: center;
cursor: pointer;
text-decoration: none;
margin-top: 10px;
}
.ub-disabled {
opacity: 0.5;
pointer-events: none;
}
#canvasWrapper {
display: none;
position: absolute;
left: 0;
top: 0;
width: 100%;
}
JavaScript
html2canvas(document.getElementById("imagewrap"), {
onrendered: function(canvas) {
canvas.className = "html2canvas";
// canvas.width = "1080";
// canvas.height = "1920";
document.getElementById("canvasWrapper").appendChild(canvas);
var image = canvas.toDataURL("image/png");
document.getElementById("downloadLink").href = image;
},
useCORS: true
});