打印页面中的div背景色不起作用 [英] div background color in print page doesn't work
问题描述
我想使用一个 div
,它有一个 background-color
,但是如果我打印页面,白色。
使用< tr bgcolor =#333333>
创建表时,它也会
如何使用 css
和 html创建一个打印页面 code>?
我的代码:
< table border =0pxcellspacing =1cellpadding = 0bgcolor =#777777width =650px>
< tr bgcolor =#999999>
< td align = right colspan = 2>< span style =font:bold 14px'b nazanin';> Text< / span>< / td>
< / tr>
< / table>
媒体查询将样式表定位到打印的方式我不相信您会找到一种通用的方式来执行您想要执行的操作(控制用户的打印机是否打印背景)而不使用PD您的内容的Fs,这可能不是可取/可行的。但是,您应该考虑特别处理您的打印样式,并且可能会避免您在打印页面的设计中使用背景。
http://www.w3.org/TR/css3-mediaqueries/编辑
看到您的其他评论,如果您必须打印背景并拥有一名用户,请教您的用户打印打印机背景。例如在Firefox中(Firefox)(复选框):
I want use a div
that has a background-color
, but if I print the page it appears in white .
When I create a table using <tr bgcolor="#333333">
it also does not work.
How I can create a print page using css
and html
?
My code :
<table border="0px" cellspacing="1" cellpadding=0" bgcolor="#777777" width="650px">
<tr bgcolor="#999999">
<td align=right colspan=2><span style="font:bold 14px 'b nazanin';">Text</span></td>
</tr>
</table>
I would look into the media query way of targeting a stylesheet to the print. I don't believe you will find a common way cross-browser of doing what you want to do (control whether the user's printer prints a background) without using PDFs of your content, which may not be desirable/doable. However, you should consider specially handling your print styles and perhaps avoid backgrounds in your design of the printed page.
http://www.w3.org/TR/css3-mediaqueries/
EDIT
Seeing your other comment, if you have to make the backgrounds print and have a single user, teach your user to make the printer print backgrounds. See for example in Firefox (checkbox):
这篇关于打印页面中的div背景色不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!