我正在使用 GWT/GXT。
我使用了 GWT 的网格,每一行都使用 CSS 以背景颜色突出显示。但应用的 css 未打印在打印页面中。我如何使用 CSS 进行打印?
我调用打印功能如下:
Print.it("<link rel='StyleSheet' type='text/css' media='paper' href='mainApplication.css'>", DOM.getElementById("myId"));
在 mainApplication.css 中,我放置了如下样式:
@media print {
print_background {
background-color: #EBECE4 !important;
}
}
我的 CSS 样式正确吗?请帮助我。
在代码中:
我创建了一个水平面板并向其添加了 GWT 网格,如下所示。
HorizontalPanel recordsPanel = new HorizontalPanel();
//GWT grid is created and the same is added to recordsPanel
recordsPanel .add(grid).
我为网格行应用了 css 样式,如下所示:
recordsGrid.getRowFormatter().addStyleName(i, "print_results_background");
现在我想用 css 样式打印记录。
谢谢!
最佳答案
您的 CSS 样式对于一个小问题是不正确的:在 print_background 类之前缺少点 (.)。正确的代码是:
@media print {
.print_background {
background-color: #EBECE4 !important;
}
}
关于java - 如何在打印时应用 CSS 样式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12456981/