问题描述
可以在Internet选项的高级选项卡中打印背景图片白色,但不启用打印背景颜色和图片。
Is possible to print a background-image whithout enabling "Print Background colors and images" in Advanced tab of Internet Options ?
我想使用替代方法background-image...使用div标签和位置绝对是可能的模拟背景图像的相同的效果吗?
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.
推荐答案
打印背景图片的能力(指定为背景的图片 - 标记中的图像)完全由最终用户决定,您无法通过代码以编程方式控制。有一个Firefox插件,提供了一个JavaScript API来控制许多打印设置 - 这可能能够控制背景图像。
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.
您可以使用绝对定位的IMG标签,并管理z-index分层容器推动IMG到后面,但TBH它开始变得凌乱,你可能无法实现你所处的影响,并保持正确的语义标记。当然,如果你想要IMG重复,你必须诉诸JavaScript来创建和定位多个IMG标签,或者创建一个你手动平铺的大图片 - 不推荐。
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.
除非有特定要求,否则用户通常不想(或需要)打印背景图片 - 因此浏览器中的轻松触及选项。所以最好重新思考这个问题。打印和屏幕是两个非常不同的媒体,所以你不一定试图模仿屏幕显示在打印,因此CSS的能力,创建打印只有样式表 - 如果这是你想实现?
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?
这篇关于在IE中打印背景图像,而不启用“打印背景颜色和图像”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!