HTML / CSS - 样式打印,背景不会出现? [英] HTML/CSS - Styling for print, background wont show up?

查看:1123
本文介绍了HTML / CSS - 样式打印,背景不会出现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在创建网站时遇到了一些麻烦,就像在浏览器中查看网站一样,无法打印。它看起来不错,唯一让我困扰的是,它拒绝显示背景。图像是好的,但它只是背景。我没有尝试将图像设置为背景,但是这不应该是必要的,对吗?

I'm having some trouble making a site, identical to viewing it in the browser, for print. It looks good, the only thing that got me stuck is that it refuses to display backgrounds. The images are fine though, it's just backgrounds. I haven't tried setting an image as a background, but that shouldn't be necessary anyways, right?

我将背景应用于DIV元素,十六进制颜色,如果这很重要。

I'm applying the background to a DIV element, with hex colors, if that matters.

有什么办法吗?我搜索它,但我没有发现任何人有同样的问题。

Is there any way around this? I searched for it but i didn't find anyone was having the same problem.

谢谢!

推荐答案

默认情况下,许多浏览器不打印背景图像和颜色。您需要在打印选项中启用。 Chrome没有该选项,但要使WebKit浏览器(Safari,Google Chrome)打印背景图片或颜色,您应该向元素添加以下CSS样式:

By default many browsers does not print background images and colours. You need to enable that in the print options. Chrome does not have that option but to make a WebKit browsers (Safari, Google Chrome) print the background image or colour you should add the following CSS style to the element:

-webkit-print-color-adjust: exact;

这篇关于HTML / CSS - 样式打印,背景不会出现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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