如何添加一个背景图像在IE / FF打印? [英] How do you add a background image for printing in IE/FF?

查看:219
本文介绍了如何添加一个背景图像在IE / FF打印?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在其他主题中,我发现 IE / FF默认不打印背景图像。现在,这是一个耻辱,因为背景图片添加一些可能性很难用古典< img> 标签重现:




  • 您可以将它们水平和垂直对齐

  • 如果它们大于目标元素,则可以裁剪它们(这也使CSS sprites )



现在,这并不是不可能的事情,但是这需要我有不同的HTML布局来打印和普通页面,打印布局会相当复杂(因为我不得不使用< table> s来实现垂直对齐)。此外,CSS精灵的好处将会丢失。



有什么希望吗?我收集了 @media print 没有帮助,但没有其他的东西,也许是浏览器特定的,这将允许人们说:是的,这不是'在正常的背景下,它真的需要在那里,甚至在打印视图中?

解决方案

不可能。你将不得不如何将你的背景图片转换为img或使用Canvas。当然使用画布取决于你支持哪个IE。

这是一个限制打印背景图片的浏览器设置。我认为这背后的逻辑是,供应商希望给用户打印背景图像的选项,并确保Web开发人员不能通过某种脚本来改变这些设置。

In other topics I've found that IE/FF doesn't print background images by default. Now that's a shame, because background images add some possibilities that are very difficult to reproduce with classical <img> tags:

  • You can align them both horizontally and vertically
  • You can crop them if they are larger than the target element (which also enables the idea of CSS sprites)

Now, it's not impossible to do, but it will require me to have different HTML layouts for printing and normal page, and the printing layout will be quite overcomplicated (since I'll have to use <table>s to achieve vertical alignment). Also, the benefits of CSS sprites will be lost.

Is there any hope? I gather that @media print doesn't help, but isn't there something else, maybe browser-specific, that would allow one to say: "Yes, this isn't a normal background, it really needs to be there even in print view"?

解决方案

Not possible. You would have to some how convert your background images to img or use Canvas. Of course using canvas depends on which IE you supporting.

Its a browser setting which restricts the printing of background images. I think the logic behind it was that the vendors wanted to give the users the option of printing background images and ensure that the web developer could not alter these settings through some sort of script.

这篇关于如何添加一个背景图像在IE / FF打印?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆