打印指定内容
<script>
print(myDiv){
var newstr = document.getElementById(myDiv).innerHTML;
let css = `<style> body{margin: 0!important;padding: 0!important;}
#mainbox {
width: 264px;
height: 146px;
position: relative;
border: 1px solid #000;
border-radius: 10px;
font-family: SimHei;
display: inline-block;
page-break-after:always;
}
#mainbox .person div {
width: 33.33%;
height: 24px;
line-height: 24px;
box-sizing: border-box;
text-align: left;
border-right: 1px solid #000;
font-size: 12px;
-webkit-transform: scale(0.917);
}
</style>`
let newWindow = window.open();
newWindow.document.write(newstr+css);
newWindow.document.close();
newWindow.print();
newWinow.close();
return;
}
</script>