[英]How can I style my pdf to have a full background?
I'm trying to create a pdf which uses css to completely style the background-color. 我正在尝试创建一个使用css来完全设置背景颜色样式的pdf。 I can't seem to get the css to give it a full background.
我似乎无法让CSS为其提供完整的背景知识。
My CSS: 我的CSS:
@media print {
@page {
background: pink !important; // not showing
margin: 0 !important;
padding: 0 !important;
-webkit-print-color-adjust: exact !important;
}
}
html, body {
box-sizing: border-box;
min-height: 100%;
min-width: 100%;
height: 100%;
width: 100%;
font-family: Montserrat;
background-color: #20333e;
color: rgba(255, 255, 255, 0.87);
border: 2px solid red;
}
Which outputs: 哪个输出:
I already have the markdown data in json format and am using the package markdown-pdf to create the pdf. 我已经有json格式的markdown数据,并且正在使用markdown-pdf包创建pdf。
import * as markdownpdf from 'markdown-pdf';
markdownpdf({cssPath: './path/to/my/ebook.css'}).from.string('# CSS Not Full Background').to("./document.pdf", function () {
console.log("done");
});
How can I style my pdf to have a full background? 如何为PDF设置样式以使其具有完整背景?
try adding top, bottom, margin values to body,html element 尝试将top,bottom,margin值添加到body,html元素
body,html{ 身体,HTML {
top: 0, bottom: 10, left: 0, right: 0 上:0,下:10,左:0,右:0
replace page{...} inside @media print with 将@media print中的页面{...}替换为
body {
background-color: pink;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.