【问题标题】:External & local CSS is not considered when rendering page to PDF using PhantomJS使用 PhantomJS 将页面呈现为 PDF 时不考虑外部和本地 CSS
【发布时间】:2019-06-07 17:51:56
【问题描述】:

有没有办法强制 PhantomJS 读取 CSS 样式?

我目前正在使用 Angular 和 UI-Grid 生成表格,当表格中的值满足条件时(例如 if value > 1000),它将被分配给特定的 CSS 类.然后我使用 PhantomJS 生成一个 PDF 文件。

CSS

.data-records-alarm {
    color: red !important;
    text-align: center;
}

我注意到它可以识别“text-align: center;”属性,但无法识别颜色“color: red !important;”。

我也试过“颜色:红色;”或移动 CSS 样式并将其放在我的 HTML 文件中,但它不起作用。

我目前使用 PhantomJS 2.0.0 并测试了 Chrome 和 Firefox 浏览器。

【问题讨论】:

    标签: css angularjs node.js phantomjs stylesheet


    【解决方案1】:

    我让它工作的唯一方法是使用-webkit-text-fill-color 而不是color

    .data-records-alarm {
        -webkit-text-fill-color: red !important;
        text-align: center;}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-03-14
      • 2016-02-14
      • 2017-03-26
      • 1970-01-01
      • 1970-01-01
      • 2013-06-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多