我正在处理一组需要打印的 HTML 报告。屏幕上看起来一切正常,但打印页面时,所有文本元素周围都会出现一个白框。
这是 HTML:
<!DOCTYPE html>
<html>
<head>
<link rel="Stylesheet" type="text/css" href="../css/style.css" media="all"/>
</head>
<body>
<div id="container">
<div id="menu">
<b>Menu</b><br>
HTML<br>
CSS<br>
JavaScript</div>
<div id="content">
Content goes here</div>
</body>
</html>
这是 CSS:
@media print
{
/* Hides elements on page when printed */
.nonPrinting
{
display: none;
}
/* Forces the background colors / images to display when printing */
body
{
-webkit-print-color-adjust : exact;
}
}
#container
{
width:500px;
}
#menu
{
background-color:#FFD700;
height:200px;
width:100px;
float:left;
}
#content
{
background-color:#EEEEEE;
height:200px;
width:400px;
float:left;
}
页面在 node-webkit 应用程序中运行。
最佳答案
您是否尝试过为这些元素分配特定的背景颜色?
尝试
background-color : transparent;
或
background-color: #FFD700;
在#menu
的子元素上
编辑
这就是“打印”pdf 对我来说的样子:
编辑:
可能是驱动问题?
关于html - 文本周围的白色边框覆盖背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17841505/