如何将打印预览的页边距设置为0?
我哪里做错了?
这是正常的打印预览:
但我想看这张图片(不拖动边距箭头)
这是CSS代码和预览:
Where am i doing wrong?
This is the normal print preview:
But I want to see this picture (without dragging margin arrows)
This is the css codes and preview:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(5)
是的。 可以更改页面打印输出中的页边距。 该规则如下所示:
目前这在 Firefox 中不起作用。 如果您在@page CSS 支持上查看他们的开发人员参考,您可以看到哪些浏览器支持
@page
。Yes. It is possible to alter your margins in a page printout. The rule would look like:
This will not work in Firefox as of now. If you check their developer reference on the @page CSS support, you can see what browsers do support
@page
.您能做的最好的事情就是设置
@page
页边距。 但请记住,如果将边距设置为 0,您可以而且很可能会被否决。The best you can do is set
@page
margins. Keep in mind, however, that you can and most likely will be overruled if you set margins to 0.谢谢 ! 在 Chrome 上运行良好
Thanks ! works well on chrome
我认为实际上不可能做到这一点,因为您会否决用户计算机上的默认设置。 据我所知,如果没有 IE 中的某种 ActiveX 脚本,Web 应用程序就没有访问权限来更改打印机设置等内容。
不久前我遇到了类似的问题,最终不得不使用 TCPDF 即时生成 PDF。 最终效果更好,因为您可以更好地控制布局。
I don't think it is actually possible to do this, because you'd be overruling the defaults on the user's computer. As far as I know, a web application doesn't have the access rights to alter something like printer settings without some kind of ActiveX script in IE.
I had a similar problem a while back, and ended up having to generate a PDF on the fly using TCPDF. In the end that worked out better, because you have greater control over the layout.
我无法将计算机从 Windows XP 升级到更新版本,所以基本上我只能使用 IE8。
我发现在 IE8 上,页边距始终至少为左右 6.01 毫米,顶部和底部 5 毫米。 无论我做什么,即使在@page规则中使用@top-left right和center规则,它仍然默认为上面的值。
创建样式表以考虑打印尺寸的这一限制可能会更容易。
将 IE hack \9 放在 CSS 类属性值前面也可能有所帮助,复制该属性在某些情况下也可能有所帮助(但不会影响页面的边距),例如:
我知道有其他与此类似的黑客,例如 \0 但我承认并不完全理解它们。 在某些情况下,\9 在 IE8 中适用于我。
I'm prevented from upgrading a computer from Windows XP to something more recent, so basically I'm stuck with IE8.
I found that on IE8, page margins will always be a minimum of 6.01mm left and right, and 5mm top and bottom. No matter what I do, even using @top-left right and centre rules inside the @page rule, it will still default to the values above.
It may be easier to create the stylesheet to take into consideration this limitation on the print size.
It may also help to put the IE hack \9 in front of the CSS class property value, duplicating the property may also help in some cases, (but won't affect the margins of the page), such as:
I know there are other hacks similar to this, such as \0 but I admit don't fully understand them. \9 works for me in IE8 in some situations.