使用Javascript在window.print中查找问题

使用Javascript在window.print中查找问题,javascript,jquery,html,css,.net,Javascript,Jquery,Html,Css,.net,我正在使用java script window.print作为我的打印div。当我打印该div时,我会在打印页面中发现对齐问题 下面是我的代码,这是我用来打印,也我上传了这两个图像。第一个是我的输出图像,第二个是我打印的布局 function PrintPopup() { var data = $("#viewCoupon").html(); var mywindow = window.open('', 'Print Data', 'height=540,wi

我正在使用java script window.print作为我的打印div。当我打印该div时,我会在打印页面中发现对齐问题

下面是我的代码,这是我用来打印,也我上传了这两个图像。第一个是我的输出图像,第二个是我打印的布局

  function PrintPopup() {
        var data = $("#viewCoupon").html();
        var mywindow = window.open('', 'Print Data', 'height=540,width=980');
        mywindow.document.write("<html><head><title>Bonus Box Offer</title>");
        mywindow.document.write("<link href=\"Content/style.css\" rel=\"stylesheet\" />");
        mywindow.document.write("<style>.userwinners{margin-top: 51px;margin-left: 0;} .no-Print{display:none;}  @media print {.no-Print{display:none;} title {display:none;} }</style>");
        mywindow.document.write("</head><body >");
        mywindow.document.write(data);
        mywindow.document.write("</body></html>");

        mywindow.document.close(); // necessary for IE >= 10
        mywindow.focus(); // necessary for IE >= 10

        mywindow.print();
        //mywindow.close();

        return true;
    }
函数printpoop(){
var data=$(“#视图优惠券”).html();
var mywindow=window.open(“”,'打印数据','高度=540,宽度=980');
mywindow.document.write(“奖金箱优惠”);
mywindow.document.write(“”);
mywindow.document.write(“.userwinners{margin top:51px;margin left:0;}.no Print{display:none;}@media Print{.no Print{display:none;}title{display:none;}”);
mywindow.document.write(“”);
mywindow.document.write(数据);
mywindow.document.write(“”);
mywindow.document.close();//对于IE>=10是必需的
mywindow.focus();//IE>=10所必需的
mywindow.print();
//mywindow.close();
返回true;
}


使用单独的CSS文件。因此,您可以使用CSS以更好的方式对齐页面。以下是CSS文件包含的代码,这是打印的唯一效果

<link rel="stylesheet" type="text/css" href="print.css" media="print">


因此,您可以添加任何CSS来对齐打印页面。

请将html代码放在此处。请阅读并使用适当的页边距格式化页面。您可以创建一个JSFIDLE吗。。为了更好地理解。。这个问题需要在您的
html
css