Skip to content

Instantly share code, notes, and snippets.

@CodeMyUI
Last active June 5, 2022 01:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save CodeMyUI/0d50f219b1f480840618c8e465a52591 to your computer and use it in GitHub Desktop.
Save CodeMyUI/0d50f219b1f480840618c8e465a52591 to your computer and use it in GitHub Desktop.
XWWEVbj
<div id="target">
CodeMyUI.com, web design inspiration and code snippets.<br/> <br/><br/>Nunc at lorem egestas, gravida lorem quis, pulvinar ante. Quisque id tempus libero. Mauris hendrerit nunc risus, ac laoreet lectus gravida et. Nam euismod magna ac enim posuere sagittis. Fusce at egestas enim, eu hendrerit enim.
</div>
<button onclick="takeScreenShot()">to image</button>
window.takeScreenShot = function() {
html2canvas(document.getElementById("target"), {
onrendered: function (canvas) {
document.body.appendChild(canvas);
},
width:320,
height:220
});
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js"></script>
#target{
width:300px;
height:200px;
background:#ff6361;
color:#fff1e9;
padding:10px;
}
button{
display:block;
height:20px;
margin-top:10px;
margin-bottom:10px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment