如何打印附有所有CSS样式的网页? [英] how can I print a web page with all its css style attached to the page?
问题描述
我想添加一个打印按钮,以使用户能够打印我的网页.但是,当我打印所有css样式时,这些样式都会丢失.看来打印机只保留基本的html元素.如果我也想完全按照浏览器的外观打印页面,该怎么办?我的意思是,如果我使用彩色打印机,它将在其上打印具有CSS样式的彩色页面.当我使用黑白打印机时,它应该将浅色打印为白色,将深色打印为灰色或黑色.
I want to add a print button to enable users to print my web page. However when I print all the css styles are lost. It seems the printer only keeps the basic html elements. If I also want to print out the page exactly as it looks like in a browser, what should I do? I mean if I use a color printer it will print a colorful page with css styles on it. When I use a black and white printer it should print light colors as white and dark colors as grey or black.
推荐答案
如果link
元素上有media="screen"
,请尝试将其删除或替换为media="all"
.
If you have media="screen"
on your link
element, try to remove it or replace with media="all"
.
这篇关于如何打印附有所有CSS样式的网页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!