如何通过CSS设置Safari打印边距以打印无边框 [英] How to set Safari print margins via CSS to print borderless

查看:4324
本文介绍了如何通过CSS设置Safari打印边距以打印无边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Safari中打印一个没有任何边距的PDF网页。页面大小在打印对话框中设置为A4 borderless。

I want to print a webpage to PDF without any margins in Safari. Page size is set to 'A4 borderless' in the print dialogue.

无论我做什么,OSX上的Safari都会在HTML上增加一个额外的边距。检查打印背景看看我的意思。

Whatever I seem to do, Safari on OSX is adding an extra margin around my HTML. Check 'print backgrounds' to see what I mean.

很明显,@ page-rule对Safari没有影响,但是还有其他方法吗?

Clearly the @page-rule has no effect for Safari, but are there any other ways?

a href =http://jsfiddle.net/willemvb/psFHC/> http://jsfiddle.net/willemvb/psFHC/

http://jsfiddle.net/willemvb/psFHC/

@page {
  size: 21cm 29.7cm;   /*A4*/
  margin: 0; /*webkit says no*/
}

html{
    margin: 0;
    padding: 0;
    width: 100%;
}

body {
    margin: 0;
    padding: 0;
    font-family: sans-serif;
    width: 100%; 
    background: #eee;
}

推荐答案

有三件事要考虑:


  1. 页面规则的边距,不幸

  1. The margin of the page's rule, unfortunately

@page {
margin: 0cm !important;
}

对Chrome 6不起作用,知道,只要Safari不支持这个,就没有解决方案(它似乎固定在10mm左右)。

Has no effect on Safari 6, where it does in Chrome 23. As I know, as long as Safari is not supporting this, there is no solution (it seems to be fixed to around 10mm).

a href =http://support.gliffy.com/entries/246980-print-on-the-mac-osx-with-no-margins =nofollow>此处您可能需要定义在打印...菜单面板中自定义纸张大小,没有任何边距(您已经是btw)。

The page setting as seen here you might have to define a custom "Paper Size" in the "Print…" menu panel without any margin (you did it already btw).

显然要照顾其他内容html,正文...无任何边距。

Obviously to take care of the other inner content html, body… not to have any margin.

这篇关于如何通过CSS设置Safari打印边距以打印无边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆