Ich benutze html2canvas-Bibliothek, um Screenshot der HTML-Ansicht zu machen.html2canvas border image issue
aber Hintergrundbild konnte nicht geladen werden. Ich erhalte Fehlermeldung Fehler, der Hintergrund lädt:
hier ist meine JSFiddle.
window.takeScreenShot = function() {
html2canvas(document.getElementById("target"), {
onrendered: function (canvas) {
document.body.appendChild(canvas);
},
useCORS:true,
logging:true,
allowTaint:true
});
}
#target{
width:300px;
height:160px;
background:lightblue;
color:#fff;
padding:10px;
background-image: url(https://static.pexels.com/photos/20974/pexels-photo.jpg);
background-repeat:no-repeat;
background-position:center center;
-o-background-size: 100%;
-moz-background-size: 100%;
-webkit-background-size: 100%;
background-size: 100%;
height: 100%;
}
#borderimg1 {
border: 10px solid transparent;
padding: 15px;
-webkit-border-image: url(https://www.w3schools.com/cssref/border.png) 30 round; /* Safari 3.1-5 */
-o-border-image: url(https://www.w3schools.com/cssref/border.png) 30 round; /* Opera 11-12.1 */
border-image: url(https://www.w3schools.com/cssref/border.png) 30 round;
}
#borderimg2 {
border: 10px solid transparent;
padding: 15px;
-webkit-border-image: url(https://www.w3schools.com/cssref/border.png) 30 stretch; /* Safari 3.1-5 */
-o-border-image: url(https://www.w3schools.com/cssref/border.png) 30 stretch; /* Opera 11-12.1 */
border-image: url(https://www.w3schools.com/cssref/border.png) 30 stretch;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js"></script>
<button onclick="takeScreenShot()">to image</button>
<div id="target">
<p>The border-image property specifies an image to be used as the border around an element:</p>
<p id="borderimg1">Here, the middle sections of the image are repeated to create the border.</p>
<p id="borderimg2">Here, the middle sections of the image are stretched to create the border.</p>
<p>Here is the original image:</p><img src="https://www.w3schools.com/cssref/border.png">
<p><strong>Note:</strong> Internet Explorer 10, and earlier versions, do not support the border-image property.</p>
</div>
Vielen Dank für Ihre Wiederholung aber. Ich denke, Problem nicht mit Proxy. Problem mit ** border-Image **. Randbildoption funktioniert nur in meiner Ursache nicht. Nur schwarze Umrandung anstelle von Bild. andere als Hintergrundbilder laden sich gut. Bitte beachten Sie das Code-Snippet oder [Jsfiddle] (http://jsfiddle.net/sodofkcs/1042/). Klicken Sie auf ** toImage **, um das Ergebnis zu sehen. Ich hoffe, Sie werden verstehen und mir helfen, dieses Problem zu lösen. Vielen Dank. –
Siehe aktualisiert [JSFIDDLE] (http://jsfiddle.net/sodofkcs/1047/). Mein Problem nur mit ** border-image **. '-webkit-border-image: URL (" http: //..*.png ") 10 Fill-Stretch; border-image-source: URL ("http: //...*.png"); ' –