繁体   English   中英

如何在javascript / css中删除窗口的边距或填充?

[英]how to remove margin or padding of window in javascript/css?

我正在尝试使用javascript打印图像:

function printImage(src){
        var printWindow = window.open('', 'Print Window','height=400,width=600');
        printWindow.document.write('<html><head><title>Print Window</title>');
        printWindow.document.write('</head><body ><img src=\'');
        printWindow.document.write(src);
        printWindow.document.write('\' /></body></html>');
        printWindow.document.close();
        printWindow.print();
}

printImage(src); //this is image src..

它打印得很好,问题在这里:

在此处输入图片说明

我要删除该空白区域,因为我将其打印在窄纸上(比尔/收据纸)。 由于存在空白,图像打印很小。 我尝试过像set style="margin-top:-25px; margin-left: -25px;" img但是它的打印像:

在此处输入图片说明

如何在left top打印image而没有任何空白空间?

帮帮我..谢谢

您可以尝试CSS @page

@page {
    size: auto;
    margin: 0;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM