Javascript设置打印样式表 [英] Javascript set print stylesheet

查看:166
本文介绍了Javascript设置打印样式表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何修改打印样式表对象的样式?我使用jQuery,如果这是任何帮助。

How would I modify the style of an object for the print stylesheet? I'm using jQuery, if that's of any help.

我基本上想设置一个对象的css属性,但有属性适用于打印,而不是屏幕。例如 $('#myobject')。css('background','white','print');

I basically want to set a css property of an object, but have that property apply for print only, not screen. e.g. $('#myobject').css('background','white','print');

推荐答案

这个问题有点模糊,所以我不知道我是否跟着你想做的。
是否正在尝试动态修改要打印的对象的样式?

This question is a little vague, so I'm not sure if I'm following what you're trying to do. Are you trying to dynamically modify the style of an object for print?

如果是这样,您可以尝试向头部添加样式,如下所示: / p>

If so, you can try adding styles to the head, like the following:

$('head').append('<style type="text/css" media="print">Whatever styles</style>');

这篇关于Javascript设置打印样式表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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