打印后不应用css [英] css is not applied after print

查看:76
本文介绍了打印后不应用css的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨.

我已经使用字符串生成器动态创建了表.

当我运行此页面时,背景色将应用于"th",但是在打印页面时,它不会打印背景色.但是,当我将字体颜色应用到"th"时,它将在打印后打印字体颜色.

 StringBuilder strhtmlcontent =  StringBuilder();
strhtmlcontent.Append("  );
strhtmlcontent.Append(" );
ttpContext.Current.Response.Write(strhtmlcontent);
HttpContext.Current.Response.Flush(); 



谢谢.

添加了[edit] pre标签-@amit [/edit]

解决方案

可以为媒体类型打印定义单独的CSS样式. 此处 [
明智的做法是设计一个单独的打印机友好样式.没有浮体或没有背景的地方,用于文本的颜色最少(尽管您需要为图像使用颜色),并且仅显示页面的内容.


Hi.

i have dynamically created table with string builder..

when i run this page background color is applied to ''th'' but when print the page it doesnt print background color. But when i applied font color to ''th'' then it prints font color after printing..

StringBuilder strhtmlcontent = new StringBuilder();
strhtmlcontent.Append("<table id='mytable' align='Center' style='background-color:#' BORDER-COLLAPSE:collapse cellSpacing=0 rules=all border=1 width=100% ><th width=8% style='background-color:Lime;'>FirstName</th>");
strhtmlcontent.Append("</table>");
ttpContext.Current.Response.Write(strhtmlcontent);
HttpContext.Current.Response.Flush();



Thanks.

[edit]pre tag added - @amit[/edit]

There is a possibility to define separate CSS styles for media type print. Here[^]''s a little article. You should find plenty like this if you Googled.

But my personal experience is, most web browsers ignore properties like background color when they print a page. The truth is, ''ability to view web pages'' being the prime objective of web browsers, most of them are not programmed smart enough to print everything they render.

A smart thing to do would be to design a separate printer friendly style. Where there are no floating bodies or no backgrounds, and minimal amount of colors used for texts (you need to use colors for images though), and the only the content of the page is displayed.


这篇关于打印后不应用css的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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