在 IE 中打印背景图像而不启用“打印背景颜色和图像”

发布于 2024-09-08 16:44:10 字数 135 浏览 1 评论 0原文

是否可以在不启用“Internet 选项”的“高级”选项卡中的“打印背景颜色和图像”的情况下打印背景图像?

我认为使用没有“背景图像”的替代方法...使用 div 标签和绝对位置可以模拟背景图像的相同效果吗?我还想在整个页面上重复背景图像。

Is possible to print a background-image whithout enabling "Print Background colors and images" in Advanced tab of Internet Options ?

I think to use a alternative way without "background-image"... Using div tag and position absolute is possible to emulate the same effect of background-image? Also I would like to repeat the background image through the page.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

云雾 2024-09-15 16:44:10

打印背景图像(在标记中指定为背景图像的那些图像)的能力完全取决于最终用户,您无法通过代码以编程方式控制它。 Firefox 有一个插件,它提供了 JavaScript API 来控制许多打印设置 - 这可能能够控制背景图像。然而,这显然只适用于 Firefox,并且取决于最终用户安装了这个特定的插件。

您可以使用绝对定位的 IMG 标签并管理分层容器的 z 索引,将 IMG 推到后面,但是说实话,它开始变得混乱,您可能无法实现您想要的效果并维护正确的语义标记。当然,如果您希望 IMG 重复,您必须使用 JavaScript 来创建和定位多个 IMG 标签,或者创建一张手动平铺的大图像 - 不推荐。

除非您有特定要求,否则用户通常不希望(或需要)打印背景图像 - 因此可以在浏览器中轻松访问选项。因此,最好重新考虑这个问题。打印和屏幕是两种截然不同的媒体,因此您不必尝试模仿打印中的屏幕显示,因此 CSS 能够创建仅打印样式表 - 如果这就是您想要实现的目标?

The ability to print background images (those images specified as background-images in the markup) is entirely up to the end user, you can not control this programmatically from your code. There is a plugin for Firefox that provides a JavaScript API to control many print settings - this might be able to control background-images. However, this obviously only works in Firefox and is dependent on the end user having this particular plugin installed.

You could use absolutely positioned IMG tags and manage the z-index of layered containers to push the IMG to the back, but TBH it's starting to get messy and you may not be able to achieve the affect you are after and maintain correct semantic markup. Certainly if you want the IMG to repeat you'd have to resort to JavaScript to create and position multiple IMG tags, or create one large image that you have manually tiled - not recommended.

Unless you have a specific requirement, users generally do not want (or need) background images to be printed - hence the easy reach option in the browser. So it may be best to rethink the problem. Print and screen are two very different media so you shouldn't necessarily try to mimic on screen display in print, hence CSS's ability to create print only stylesheets - if that is what you are trying to achieve?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文