html - 打印网页不会显示打印 View 并打印空白

标签 html css angularjs printing preview

我在需要打印的网页中创建了表格。在主页上,我有一个 printerFriendly 按钮,可以打开一个新选项卡,该选项卡仅显示我需要打印的表格和内容。当我转到新选项卡并尝试打印或获取打印预览时,它完全是空白的。我可以做一些设置或代码中的某些东西来解决这个问题吗?我也在使用 angularjs。这发生在 Chrome 和 IE 中。任何帮助表示赞赏。 *如果需要显示任何代码,请告知。不确定是代码还是打印设置。

此代码使内容显示在打印预览中 已更新

   @media print {

    body *{
        font-family: 'Open Sans', sans-serif;
        font-size: 12px;
        font-weight: 500;
        color: #101010;
        background: #f6f5fa;
        visibility: hidden;
    }
  #section-to-print, #section-to-print *{
    visibility: visible;
  }
  #section-to-print {
    position:absolute; 
    left:0;
    top:0;
  }

   #section-to-print2, #section-to-print2 *{
    visibility: visible;
  }
  #section-to-print2 {
    position:absolute; 
    left:0;
    top:0;
  }

}

最佳答案

请检查下面的代码,它在打印预览中显示的内容。

JS Fiddle

HTML:

    <a href="javascript:window.print()">Print this page</a>
    <br>
    <div id="section-to-print">
      I crea    ted tables in a web page that I need to print. On the main page I have a printerFriendly button that opens a new tab that shows just the table and content I need printed. When I go to the new tab and try to print or get a print preview, it is completely blank. There is some setting or something in the code I can do to fix this? I am also using angularjs. This happens in Chrome and IE. Any help is appreciated. *If any code needs to be shown, please let know. Not sure if it is the code or the print settings.
    </div>

CSS:

        @media print {
        body *{
            font-family: 'Open Sans', sans-serif;
            font-size: 12px;
            font-weight: 500;
            color: #101010;
            background: #f6f5fa;
            visibility: hidden;
        }
      #section-to-print, #section-to-print *{
        visibility: visible;
      }
      #section-to-print {
        position:absolute; 
        left:0;
        top:0;
      }
    }

关于html - 打印网页不会显示打印 View 并打印空白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41900754/

相关文章:

html - 重置 CSS :nth-of-type counter

javascript - 无法将一个应用程序模块注入(inject)另一个 AngularJS

c# - Selenium - 返回 LinkText 找到的元素的 xpath 或 CSS 路径

javascript - 如何通过svg绘制线性渐变圆圈?

javascript - Jquery css z-index Math.random() 不工作

javascript - java脚本中的2*2矩阵运算输入。从用户到文本框的矩阵

javascript - AngularJS:如何获取 $http 结果作为函数的返回值?

javascript - init 上的 api 调用和参数更改

html - 使内部容器以 flex 布局适合屏幕大小

html - 更改悬停/事件按钮