我正在使用dompdf将HTML转换为pdf文件.一切正常.但是问题是我需要第一页以外的所有页面都有页边距.第一页应该有一张覆盖整个页面的图像.但是现在,包括第一页在内的所有页面的利润都在增加.
我无法为第一页禁用边距.任何帮助是极大的赞赏.提前致谢.
以下是我的CSS
body { margin: 0px; }
@page { margin: 50px; }
#header {
position: fixed;
left: 0px;
top: -52px;
height: 50px;
border-bottom: 2px solid #797979;
margin: 0;
}
#footer {
position: fixed;
left: 0px;
bottom: -52px;
height: 50px;
border-top: 2px solid #797979;
margin: 0;
}
#footer .page:after { content: counter(page); }
.firstpage {
position: absolute;
page-break-after: always;
top: -50px;
width: 100%;
margin: 0;
}
.otherpages{ margin: 0; }
这是我的html
some content
解决方法:
尝试这个,
@page { margin: 50px 0; }
.firstpage {
position: absolute;
page-break-after: always;
top: -50px; // compensating for @page top margin
width: 100%;
margin: 0;
}
.otherpages{ margin: 0 50px; }
标签:dompdf,css,html,php
来源: https://codeday.me/bug/20191027/1943218.html