I searched a lot before asking here, but didn't find an answer for my question.
在问这里之前我搜索了很多,但没有找到我的问题的答案。
I want to insert top and bottom margin for my website page when printed, so I used the normal margin-top
and margin-bottom
for the printed div but it affected on the first sheet only! so I used this as explained in W3C CSS2.1 Specifiction:
我想在打印时为我的网站页面插入顶部和底部边距,所以我使用了正常的margin-top和margin-bottom来打印div,但它仅在第一张纸上受到影响!所以我按照W3C CSS2.1规定的说明使用了这个:
@page {
margin-top: 5cm;
margin-bottom: 5cm;
}
but no effect in Firefox Print Preview or Print to PDF. so how can I insert top and bottom margin (for each printed sheet) via CSS? or is there any trick to do this in Firefox?
但在Firefox打印预览或打印到PDF中没有效果。那么如何通过CSS插入顶部和底部边距(对于每张打印的纸张)?或者在Firefox中有什么技巧可以做到这一点?
2 个解决方案
#1
9
Both
都
@page {
margin-top: 5cm;
margin-bottom: 5cm;
}
and
和
@media print {
body {margin-top: 50mm; margin-bottom: 50mm;
margin-left: 0mm; margin-right: 0mm}
}
work fine in Firefox 35
在Firefox 35中正常工作
#2
2
This should work even in firefox
这甚至可以在firefox中使用
@media print {
#main{margin:100px 0;}
}
The "@media print" will make sure the style is only used when printing.
“@media print”将确保仅在打印时使用该样式。
#1
9
Both
都
@page {
margin-top: 5cm;
margin-bottom: 5cm;
}
and
和
@media print {
body {margin-top: 50mm; margin-bottom: 50mm;
margin-left: 0mm; margin-right: 0mm}
}
work fine in Firefox 35
在Firefox 35中正常工作
#2
2
This should work even in firefox
这甚至可以在firefox中使用
@media print {
#main{margin:100px 0;}
}
The "@media print" will make sure the style is only used when printing.
“@media print”将确保仅在打印时使用该样式。