html - 使用 css(使用 chrome)禁用打印机默认边距?

标签 html css google-chrome printing margins

使用 Adob​​e Indesign 可以获得以下结果:

enter image description here

我尝试用 css 得到相同的结果

<style type="text/css" media="print">
@page 
{
    size: auto;   /* auto is the initial value */
    margin: 0mm;  /* this affects the margin in the printer settings */
}

body 
{
    background-color:#FFFFFF; 
    border: solid 1px black ;
    margin: 0px;  /* this affects the margin on the content before sending to   printer */
   }
</style>

但不可能将边距设置为 0。我总是在 4 边有边距:

enter image description here 我正在使用谷歌浏览器进行测试。我也尝试过:

enter image description here

同样的情况,4 边有一些小白边...怎么了?

如有任何帮助,我们将不胜感激。 JsFiddle:https://jsfiddle.net/L63dc1yd/

最佳答案

我认为你可以用CSS3 Media Query解决这个问题.

@media print {
    html,body {
        margin: 0;
    }
}

关于html - 使用 css(使用 chrome)禁用打印机默认边距?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34913242/

相关文章:

javascript - 可编辑 div 中的文本计数和子字符串

html - 包装 <pre> 标签 - 仅部分工作

javascript - 如何使用 <a> 标记内的按钮单击以防止链接被跟踪?

javascript - Facebook 是如何检测到我的浏览器窗口需要关闭的?

html - 如何防止 Chrome 占用 100% 的窗口高度?

javascript - 无法通过内容脚本使用 jQuery 更改 HTML 元素的样式

javascript - 将代码片段转换为 HTML 页面

javascript - 为什么 getAllResponseHeaders() 输出与浏览器看到的不同?

javascript - 如何设置数组以便在不使用 jQuery 的情况下获取单选按钮值

css - 将图像放在文本的左侧,没有这种楼梯效果