小编Raj*_*aja的帖子

css打印介质查询仅打印第一页

我使用Print Media Query在我的网页上打印可滚动的DIV(主DIV包含一个子DIV和表,其中有几行和来自kendo网格的自定义样式).window.Print()仅在IE 9和Chrome中打印一页,其中包括DIV内容的其余部分.我如何确保它在多个页面中打印所有内容.我在Firefox上看过类似的帖子,但使用overflow:visible!important的解决方案对我来说并不适用.以下是我的风格

注意:我尝试过使用position:absolute,height/width:100%并为Table,TBody,TR和TD设置如下设置,但没有用.

@media print {

body * {
    visibility: hidden;
  }

#divname, #divname* {
    visibility: visible;
  }

#divname
    {
        overflow: visible !important; 
        float:none !important;
        position: fixed;
        left: 0px;
        top: 0px;
        display:block !important;
        /*height:auto !important;*/
    }
}
Run Code Online (Sandbox Code Playgroud)

编辑:我终于通过读取DOM来打印,如下所示.万一,如果它可以帮助某人

    `//get DIV content as clone
    var divContents = $("#DIVNAME").clone();
    //detatch DOM body
    var body = $("body").detach();
    //create new body to hold just the DIV contents
    document.body = document.createElement("body");
    //add DIV content to body
    divContents.appendTo($("body"));
    //print body
    window.print();
    //remove body with …
Run Code Online (Sandbox Code Playgroud)

html css printing

12
推荐指数
3
解决办法
3万
查看次数

标签 统计

css ×1

html ×1

printing ×1