外部样式表和@media打印

时间:2015-10-08 16:36:08

标签: css

使用打印样式表和@media打印时,我看到的结果不一致。 我什么时候应该使用其中一个或两个?

print.css

#rptViewer 
{
    display: none;
    visibility: hidden;
}

#printReport
{
     visibility: visible;
                height: 100%;
                font: small;
                background: #eee;
                position: relative;
                margin-left: 0;
                width: 100%;
                display: table;
                margin: 0 auto;
                overflow-x:scroll;
                white-space: nowrap;
                overflow:visible !important;
                border : solid 2px;
}
html, body
{
    height:100%;
    width:100%;
}

此报告的css打印样式表剪切的外部链接仅显示滚动条或图像,并且不打印整个页面。如果我在aspx页面中包含@media print,它会正确打印它(不会切断报表,也不会像滚动条那样)。这两个方面有什么区别。 @media打印也适用于所有版本的IE。客户端使用IE 8.

如果我注释掉了样式类型= text / css和@media print chunk,那么它全部搞砸了并且只打印了一半的页面。 我正在使用window.print()

这是Aspx页面看起来的方式

 <link href="Style/print.css"  type="text/css" rel="Stylesheet" media="print" />
<style type="text/css">
        @media print
        {
           html, body
            {
                height: 100%;
                width:100%;
            }

            #rptViewer
            {
                display: none;
                visibility: hidden;
            }


            #printReport
            {
                visibility: visible;
                height: 100%;
                font: small;
                background: #eee;
                position: relative;
                margin-left: 0;
                width: 100%;
                display: table;
                margin: 0 auto;
                overflow-x:scroll;
                white-space: nowrap;
                overflow:visible !important;
                border : solid 2px;
            }

            body
            {
                background: white;
                font-size: 12pt;
                margin: 0px;

            }
        }

    </style>

这里有两种方法:一种是外部css,另一种是@media print。 如果我在aspx文件中包含@media print,它会像这样打印并且不会切断报告。

0 个答案:

没有答案