gpt4 book ai didi

javascript - @page margin 设置只适用于谷歌浏览器

转载 作者:行者123 更新时间:2023-11-28 13:43:57 25 4
gpt4 key购买 nike

我正在尝试为我的用户覆盖默认页面设置页边距。我需要他们打印的文档需要去掉边距。经过大量查找后,我发现了以下内容,并且它在 GOOGLE CHROME 中有效:

@page{
margin-left: 5px;
margin-right: 5px;
margin-top: 5px;
margin-bottom: 5px;
}

当我在 Chrome 中将其打印为 PDF 时,打印出的文档四周几乎没有边距。但是,当我在 FF4 和 IE9 中执行完全相同的操作时,它会打印出默认页边距较大的文档。

关于如何使它也适用于 IE9 和 FF 的任何想法?据说 @page CSS 是 CSS2.1 规范的一部分,所有浏览器 IE8 和更高版本都支持。所以,我不确定为什么它不适用于这些部分,以及为什么 Chrome 是唯一拥有它的浏览器。

最佳答案

不要使用px

The page context has no notion of fonts, so 'em' and 'ex' units are not allowed. Percentage values on the margin properties are relative to the dimensions of the page box; for left and right margins, they refer to the width of the page box while for top and bottom margins, they refer to the height of the page box. All other units associated with the respective CSS 2.1 properties are allowed.

Specs

关于javascript - @page margin 设置只适用于谷歌浏览器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6348882/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com