我正在尝试创建一个 pdf,它使用 css 来完全设置背景颜色的样式。我似乎无法获得 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;
}
哪些输出:
我已经有了 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");
});
如何设置我的 pdf 样式以获得完整背景?
最佳答案
尝试给 body,html 元素添加 top, bottom, margin 值
正文,html{
上:0,下:10,左:0,右:0
关于javascript - 我如何设计我的 pdf 以获得完整的背景?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50577827/